Im doing this
spl_autoload_register();
I have a folder called libs where all my files go like : user.php / orm.php etc and inside each class I have it like this
namespace libs;
class User { }
Calling the class like this
$app = new libs\User;
That seems to work but what should I do if for example I want to autoload a class that its not just inside libs folder, its for example inside :
libs / example / example.php
How should I autoload that class too?
Provided the class definition and namespace looks like this...
The autoloader should be able to find it.
Note that the default
spl_autoload
lowercases the namespaces and class names so your file names and paths should all be lowercase (which you already appear to be doing but just thought I'd mention it).Also note, for consistency, you should also set the appropriate autoload extensions, eg