title: PHP namespacing and spl_autoload_register
body: <p>I had spl_autoload_register working fine but then I decided to add some namespacing to bring in PSR2 compliance and can't seem to get it working.</p>
  
  <p>Directory strcuture:</p>
  
  <pre><code>-index.php
  -classes/
    -Class1.class.php
    -Class2.class.php
    -Class3.class.php
  </code></pre>
  
  <p>Each class starts with:</p>
  
  <pre><code>namespace Foo;
  
  Class ClassX {
  </code></pre>
  
  <p>Index.php:</p>
  
  <pre><code>&lt;?php
  
  spl_autoload_register(function($class) {
      include 'classes/' . $class . '.class.php';
  });
  
  $myObj = new Class1();
  
  echo $myObj-&gt;doSomething();
  </code></pre>
  
  <p>This products an error <code>Fatal error: Class 'Class1' not found in /var/www/myApp/index.php on line X</code></p>
  
  <p>My first thought was that I need to use a namespace with my instantiation, so I changed <code>index.php</code> to:</p>
  
  <pre><code>$myObj = new Foo\Class1();
  </code></pre>
  
  <p>However, then I get 
  <code>Warning: include(classes/Foo\Class1.class.php): failed to open stream: No such file or directory in /var/www/myApp/index.php on line 6</code></p>
  
  <p>If I do manual includes everything works fine,<code>include 'classes/Class1.class.php';</code> and so on.</p>