PHP mvc autoloader not loading classes/functions
<p><strong>I don't know why my autoloader class doesn't work.</strong><br>
<strong>I get the following error:</strong>
<em>Fatal error: Class 'files\testmodel' not found in D:\wamp\www\Opdrachten\MVC-eindopdracht\app\controllers\content.php on line 10</em></p>

<p><strong>Autoloader Class:</strong>
In app/core/autoloader.php</p>

<pre><code>class Autoloader
    {
    protected $directories = array();

private function loadClass($class)
{
    if ($class[0] == '\\')
    {
        $class = substr($class, 1);
    }

    $class = str_replace(array('\\', '_'), '/', $class). '.php';

    foreach ($this-&gt;directories as $directory)
    {
        if (file_exists($path = $class))
        {
            require_once $path;
            echo $path;
            return true;
        }
    }
}

public function register()
{
    spl_autoload_extensions('php');
    spl_autoload_register(array($this, 'loadClass'));
}

public function addDirectories($directories)
{
    $this-&gt;directories = (array) $directories;
}

}
</code></pre>

<p><strong>My Index.php</strong></p>

<pre><code>use app\core as core;
use app\lib as lib;


include('./app/core/autoloader.php');

$autoloader = new Autoloader();
$autoloader-&gt;addDirectories(
    array(
        'lib',
        'controllers',
        'core',
        'models'
        ));


$autoloader-&gt;register();

$route = new core\Router();
$route-&gt;route();
</code></pre>

<p><strong>My test class</strong> app/models/files/testmodal.php</p>

<pre><code>namespace files;
class testmodel
{
    public function $user;
    public function test()
    {
        $user = 'pieter';
        return $user;
    }
}
</code></pre>

<p><strong>Content class:</strong> in app/controllers/content.php</p>

<pre><code>class content
{
    public $title;
    public $data;

    public function __construct()
    {
        $this-&gt;_model = new files\testmodel();
    }

    public function home()
    {
        $this-&gt;title = "Home";
        $this-&gt;data = array('test', 'test123', 'test456');

        $user = $this-&gt;_model-&gt;test();
        $this-&gt;user = $user;

    }
}
</code></pre>