I have a following directory structure in my project:
Test
--Cats
----Fatty.php // namespace: Test\Cats
--index.php
index.php:
spl_autoload_extensions(".php");
spl_autoload_register();
Test\Cats\Fatty::fattyMeow();
The error I'm getting:
Fatal error: Class 'Test\Cats\Fatty' not found in /var/www/public/Test/index.php on line 9
According to this comment at php.net, spl_autoload_register()
should work just fine without any autoload
function provided if namespaces match the directory structure of the project. So, Why the code above doesn't work? Or did I misunderstood something?