Have you considered explicit definitions of your class locations? Sometimes it makes a lot of sense to group related classes.
Here is a proven way of handling it.
This code is placed in an auto_prepend_file
(or included first)
class Import
{
public static $_AutoLoad = array();
public static $_Imported = array();
public static function Load($sName)
{
if(! isset(self::$_AutoLoad[$sName]))
throw new ImportError("Cannot import module with name '$sName'.");
if(! isset(self::$_Imported[$sName]))
{
self::$_Imported[$sName] = True;
require(self::$_AutoLoad[$sName]);
}
}
public static function Push($sName, $sPath)
{
self::$_AutoLoad[$sName] = $sPath;
}
public static function Auto()
{
function __autoload($sClass)
{
Import::Load($sClass);
}
}
}
And in your bootstrap file, define your classes, and what file they are in.
//Define autoload items
Import::Push('Admin_Layout', App::$Path . '/PHP/Admin_Layout.php');
Import::Push('Admin_Layout_Dialog', App::$Path . '/PHP/Admin_Layout.php');
Import::Push('FileClient', App::$Path . '/PHP/FileClient.php');
And lastly, enable AutoLoad by calling
Import::Auto()
One of the nice things is that you can define "Modules":
Import::Push('MyModule', App::$Path . '/Module/MyModule/Init.php');
And then load them explicitly when needed:
Import::Load('MyModule');
And one of the best parts is you can have additional Import::Push
lines in the module, which will define all of its classes at runtime.