diff --git a/public/index.php b/public/index.php index 2e067c82..42cb6754 100644 --- a/public/index.php +++ b/public/index.php @@ -8,6 +8,8 @@ * @link http://laravel.com */ +$time = microtime(true); + // -------------------------------------------------------------- // Define the framework paths. // -------------------------------------------------------------- @@ -15,8 +17,12 @@ define('APP_PATH', realpath('../application').'/'); define('SYS_PATH', realpath('../system').'/'); define('CONFIG_PATH', APP_PATH.'config/'); +define('LIBRARY_PATH', APP_PATH.'libraries/'); +define('MODEL_PATH', APP_PATH.'models/'); define('PACKAGE_PATH', APP_PATH.'packages/'); define('PUBLIC_PATH', realpath(__DIR__.'/')); +define('ROUTE_PATH', APP_PATH.'routes/'); +define('VIEW_PATH', APP_PATH.'views/'); // -------------------------------------------------------------- // Define the PHP file extension. @@ -32,7 +38,25 @@ // -------------------------------------------------------------- // Register the auto-loader. // -------------------------------------------------------------- -spl_autoload_register(require SYS_PATH.'loader'.EXT); +spl_autoload_register(function($class) +{ + $file = strtolower(str_replace('\\', '/', $class)); + + if (array_key_exists($class, $aliases = System\Config::get('aliases'))) + { + return class_alias($aliases[$class], $class); + } + + foreach (array(BASE_PATH, MODEL_PATH, LIBRARY_PATH) as $directory) + { + if (file_exists($path = $directory.$file.EXT)) + { + require $path; + + return; + } + } +}); // -------------------------------------------------------------- // Set the error reporting and display levels. @@ -91,9 +115,9 @@ // ---------------------------------------------------------- if (is_null($response)) { - $route = System\Router::route(Request::method(), Request::uri()); + $route = System\Router::route(System\Request::method(), System\Request::uri()); - $response = (is_null($route)) ? System\Response::make(View::make('error/404'), 404) : $route->call(); + $response = (is_null($route)) ? System\Response::make(System\View::make('error/404'), 404) : $route->call(); } else { @@ -121,4 +145,6 @@ // -------------------------------------------------------------- // Send the response to the browser. // -------------------------------------------------------------- -$response->send(); \ No newline at end of file +$response->send(); + +echo (microtime(true) - $time) * 1000; \ No newline at end of file