In my PHP project all of the class files are contained in a folder called 'classes'. There is one file per class and as more and more functionality is added to the application the classes folder is growing larger and less organized. Right now this code, in an initialization file, autoloads classes for the pages in the app:
spl_autoload_register(function($class) {
require_once 'classes/' . $class . '.php';
});
If subfolders were to be added to the existing 'classes' folder and the class files organized within these subfolders, is there a way to modify the the autoload code so it still works?
For example - assume the subfolders within the classes folder looks like this:
- DB
- login
- cart
- catalog