handle(); }); set_error_handler(function($number, $error, $file, $line) use ($error_dependencies) { call_user_func($error_dependencies); $e = new \ErrorException($error, $number, 0, $file, $line); Exception\Handler::make(new Exception\Examiner($e, new File))->handle(); }); register_shutdown_function(function() use ($error_dependencies) { if ( ! is_null($error = error_get_last())) { call_user_func($error_dependencies); $e = new \ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']); Exception\Handler::make(new Exception\Examiner($e, new File))->handle(); } }); // -------------------------------------------------------------- // Set the default timezone. // -------------------------------------------------------------- date_default_timezone_set(Config::get('application.timezone')); // -------------------------------------------------------------- // Load all of the core routing and response classes. // -------------------------------------------------------------- require SYS_PATH.'input'.EXT; 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/handler'.EXT; // -------------------------------------------------------------- // Load the session. // -------------------------------------------------------------- if (Config::get('session.driver') != '') Session\Manager::driver()->start(Cookie::get('laravel_session')); // -------------------------------------------------------------- // Load the packages that are in the auto-loaded packages array. // -------------------------------------------------------------- if (count(Config::get('application.packages')) > 0) { require SYS_PATH.'package'.EXT; Package::load(Config::get('application.packages')); } // -------------------------------------------------------------- // Initialize the request instance for the request. // -------------------------------------------------------------- $request = new Request($_SERVER); IoC::container()->instance('laravel.request', $request); // -------------------------------------------------------------- // Hydrate the input for the current request. // -------------------------------------------------------------- $request->input = new Input($request->method(), $request->is_spoofed(), $_GET, $_POST, $_FILES, new Cookie($_COOKIE)); // -------------------------------------------------------------- // Route the request and get the response from the route. // -------------------------------------------------------------- $route = IoC::container()->resolve('laravel.routing.router')->route(); $response = ( ! is_null($route)) ? IoC::container()->resolve('laravel.routing.handler')->handle($route) : new Error('404'); // -------------------------------------------------------------- // Stringify the response. // -------------------------------------------------------------- $response->content = $response->render(); // -------------------------------------------------------------- // Close the session. // -------------------------------------------------------------- if (Config::get('session.driver') != '') { $driver = Session\Manager::driver(); $driver->flash('laravel_old_input', $request->input->get()); $driver->close(); if ($driver instanceof Session\Sweeper and mt_rand(1, 100) <= 2) { $driver->sweep(time() - (Config::get('session.lifetime') * 60)); } } // -------------------------------------------------------------- // Send the response to the browser. // -------------------------------------------------------------- $response->send();