$config) { if ($config['auto']) Bundle::start($bundle); } /** * Register the "catch-all" route that handles 404 responses for * routes that can not be matched to any other route within the * application. We'll just raise the 404 event. */ Routing\Router::register('*', '(:all)', function() { return Event::first('404'); }); /** * If the requset URI has too many segments, we will bomb out of * the request. This is too avoid potential DDoS attacks against * the framework by overloading the controller lookup method * with thousands of segments. */ $uri = URI::current(); if (count(URI::$segments) > 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); $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');