15) { throw new \Exception("Invalid request. Too many URI segments."); } /** * Route the request to the proper route in the application. If a * route is found, the route will be called via the request class * static property. If no route is found, the 404 response will * be returned to the browser. */ Request::$route = Routing\Router::route(Request::method(), $uri); if (is_null(Request::$route)) { Request::$route = new Routing\Route('GET /404', array(function() { return Response::error('404'); })); $response = Response::error('404'); } $response = Request::$route->call(); /** * Close the session and write the active payload to persistent * storage. The session cookie will also be written and if the * driver is a sweeper, session garbage collection might be * performed depending on the "sweepage" probability. */ if (Config::get('session.driver') !== '') { Session::save(); } /** * Send all of the cookies to the browser. The cookies are * stored in a "jar" until the end of a request, primarily * to make testing the cookie functionality of the site * much easier since the jar can be inspected. */ Cookie::send(); /** * Send the final response to the browser and fire the * final event indicating that the processing for the * current request is completed. */ $response->send(); Event::fire('laravel: done');