Before you try to execute require , you need to check the file with is_file() .
When using spl_autoload_register() I found that it is best to register one method for including files. The fact that you can use several functions, I believe it is easier to interact with different libraries (so that they are not clobber __autoload() ). It will also save you the need to write code repeatedly to check an existing file, match _ with a directory delimiter (if you do), etc.
So, if you change your file names according to the Underscore_Separated_Name convention, for example. Controller_Admin_Dashboard , you can use ...
function autoload($className) { $path = SYSPATH . str_replace("_", DIRECTORY_SEPARATOR, strtolower($className)) . ".php"; if (is_file($path)) { require $path; } }
The first time you create an instance of Controller_Admin_Dashboard , PHP may include a file, such as /app/controller/admin/dashboard.php .
alex
source share