123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- $start = microtime(true);
- define('APP_PATH', realpath('../application').'/');
- define('SYS_PATH', realpath($system = '../system').'/');
- define('BASE_PATH', realpath(str_replace('system', '', $system)).'/');
- define('PUBLIC_PATH', realpath(__DIR__).'/');
- $constants = array(
- 'CACHE_PATH' => APP_PATH.'storage/cache/',
- 'CONFIG_PATH' => APP_PATH.'config/',
- 'DATABASE_PATH' => APP_PATH.'storage/db/',
- 'LANG_PATH' => APP_PATH.'lang/',
- 'LIBRARY_PATH' => APP_PATH.'libraries/',
- 'MODEL_PATH' => APP_PATH.'models/',
- 'PACKAGE_PATH' => APP_PATH.'packages/',
- 'ROUTE_PATH' => APP_PATH.'routes/',
- 'SCRIPT_PATH' => PUBLIC_PATH.'js/',
- 'SESSION_PATH' => APP_PATH.'storage/sessions/',
- 'STORAGE_PATH' => APP_PATH.'storage/',
- 'STYLE_PATH' => PUBLIC_PATH.'css/',
- 'VIEW_PATH' => APP_PATH.'views/',
- );
- foreach ($constants as $key => $value)
- {
- define($key, $value);
- }
- unset($constants, $system);
- define('EXT', '.php');
- require SYS_PATH.'config'.EXT;
- require SYS_PATH.'arr'.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;
- }
- }
- });
- System\Benchmark::$marks['laravel'] = $start;
- error_reporting(E_ALL | E_STRICT);
- ini_set('display_errors', 'Off');
- set_exception_handler(function($e)
- {
- require_once SYS_PATH.'error'.EXT;
- System\Error::handle($e);
- });
- set_error_handler(function($number, $error, $file, $line)
- {
- require_once SYS_PATH.'error'.EXT;
- System\Error::handle(new ErrorException($error, $number, 0, $file, $line));
- });
- register_shutdown_function(function()
- {
- if ( ! is_null($error = error_get_last()))
- {
- require_once SYS_PATH.'error'.EXT;
-
- System\Error::handle(new ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']));
- }
- });
- date_default_timezone_set(System\Config::get('application.timezone'));
- if (System\Config::get('session.driver') != '')
- {
- System\Session::load(System\Cookie::get('laravel_session'));
- }
- require SYS_PATH.'request'.EXT;
- require SYS_PATH.'response'.EXT;
- require SYS_PATH.'routing/route'.EXT;
- require SYS_PATH.'routing/router'.EXT;
- require SYS_PATH.'routing/loader'.EXT;
- require SYS_PATH.'routing/filter'.EXT;
- System\Routing\Filter::register(require APP_PATH.'filters'.EXT);
- $response = System\Routing\Filter::call('before', array(), true);
- if (is_null($response))
- {
- $route = System\Routing\Router::make(System\Request::method(), System\Request::uri(), new System\Routing\Loader(APP_PATH))->route();
- $response = (is_null($route)) ? System\Response::error('404') : $route->call();
- }
- else
- {
- $response = System\Response::prepare($response);
- }
- System\Routing\Filter::call('after', array($response));
- $response->content = (string) $response->content;
- if (System\Config::get('session.driver') != '')
- {
- System\Session::close();
- }
- $response->send();
|