title: PHP Autoload with spl_autoload_register in a sub folder
body: <p>My directory structure is something like below</p>
  
  <pre><code>&gt; Root
  &gt; -Admin // admin area
  &gt; --index.php // admin landing page, it includes ../config.php
  &gt; -classes // all classes
  &gt; ---template.php 
  &gt; ---template_vars.php // this file is used inside template.php as $template_vars = new tamplate_vars();
  &gt; -templates // all templates in different folder
  &gt; --template1
  &gt; -index.php
  &gt; -config.php
  </code></pre>
  
  <p>in my config.php file i have used</p>
  
  <pre><code>&lt;?php
  .... // some other php code
  spl_autoload_register(NULL, FALSE);
  spl_autoload_extensions('.php');
  spl_autoload_register();
  
  classes\template::setTemplate('template/template1');
  classes\template::setMaster('master');
   .... // some other php code
  ?&gt;
  </code></pre>
  
  <p>I have set the proper namespaces (only in classes) and in my index.php on root I access the classes </p>
  
  <pre><code>&lt;?php 
  
  require 'config.php';
  $news_array = array('news1', 'news1'); // coming from database
  
  $indexTemplate = new \classes\template('index');
  $indexTemplate-&gt;news_list = $news_array; // news_list variable inside index template is magically created and is the object of template_vars class
  $indexTemplate-&gt;render();
  ?&gt;
  </code></pre>
  
  <p>So far it is working perfect, it renders the template and populate the template vars,</p>
  
  <p>but when I open index file in admin folder, it gives following error</p>
  
  <blockquote>
    <p>Fatal error: Class 'classes\template_vars' not found in
    /home/aamir/www/CMS/classes/template.php on line 47</p>
  </blockquote>
  
  <p>any idea how to fix this thing. It works on root, but from inside admin panel it doesnot work </p>