I made a simple autoloader using spl_autoloader_register function, it works fine on my virtual server, but in the server I only got "Fatal Error: Class 'X' not found". Im running it on a mac with PHP 5.4, but it also works in windows/ubuntu with 5.3 version, which is the same as my physic server. I don't have SSH access to it. Here is my autoload code:
class Load { public static function autoload($class) { $class = strtolower($class); $lib = $_SERVER['DOCUMENT_ROOT'] . BASENAME . "/libs/{$class}.php"; $model = $_SERVER['DOCUMENT_ROOT'] . BASENAME . "/models/{$class}.class.php"; $controller = $_SERVER['DOCUMENT_ROOT'] . BASENAME . "/controllers/{$class}.php"; if(is_readable($lib)){ require_once $lib; }elseif (is_readable($model)) { require_once $model; }elseif (is_readable($controller)){ require_once $controller; } } } spl_autoload_register("Load::autoload"); I always used spl for local apps, but its the first time I'm trying it on the server. Any advice for better practices will be helpful. Thanks
spl_autoload_register. If it'sFALSE, something went wrong with the registering.$lib,$modeland$controllervariables contain the right path.