PHP class not found when using namespace
<p>I am new with this namespace thing.</p>

<p>I have 2 classes(separate files) in my base directory, say <code>class1.php</code> and <code>class2.php</code> inside a directory <code>src/</code>.</p>

<p><strong>class1.php</strong></p>

<pre><code>namespace \src\utility\Timer;

class Timer{
    public static function somefunction(){

    }
}
</code></pre>

<p><strong>class2.php</strong></p>

<pre><code>namespace \src\utility\Verification;
use Timer;

class Verification{
     Timer::somefunction();
}
</code></pre>

<p>When I execute <code>class2.php</code>, i get the Fatal error that</p>

<blockquote>
  <p>PHP Fatal error:  Class 'Timer' not found in path/to/class2.php at
  line ***</p>
</blockquote>

<p>I read somewhere on SO, that I need to create Autoloaders for this. If so, how do I approach into creating one, and if not, then what else is the issue?</p>

<p><strong>UPDATE</strong></p>

<p>I created an Autoloader which will <code>require</code> all the required files on top of my php script.
So, now the class2.php would end up like this.</p>

<pre><code>namespace \src\utility\Verification;
require '/path/to/class1.php'
use Timer;
//or use src\utility\Timer ... both doesn't work.

class Verification{
     Timer::somefunction();
}
</code></pre>

<p>This also does not work, and it shows that class not found. But, if I remove all the <code>namespaces</code>, and <code>use</code>'s. Everything works fine.</p>