diff --git a/laravel/laravel.php b/laravel/laravel.php index a7cad554..97e4e750 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -1,61 +1,70 @@ $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. - */ +/* +|-------------------------------------------------------------------------- +| Register The Catch-All Route +|-------------------------------------------------------------------------- +| +| This route will catch all requests that do not hit another route in +| the application, and will raise the 404 error event so the error +| can be handled by the developer in their 404 event listener. +| +*/ + 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. - */ +/* +|-------------------------------------------------------------------------- +| Route The Incoming Request +|-------------------------------------------------------------------------- +| +| Phew! We can finally route the request to the appropriate route and +| execute the route to get the response. This will give an instance +| of the Response object that we can send back to the browser +| +*/ + $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. - */ +/* +|-------------------------------------------------------------------------- +| Persist The Session To Storage +|-------------------------------------------------------------------------- +| +| If a session driver has been configured, we will save the session to +| storage so it is avaiable for the next request. This will also set +| the session cookie in the cookie jar to be sent to the user. +| +*/ + 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. - */ +/* +|-------------------------------------------------------------------------- +| Let's Eat Cookies +|-------------------------------------------------------------------------- +| +| All cookies set during the request are actually stored in a cookie jar +| until the end of the request so they can be expected by unit tests or +| the developer. Here, we'll push them out to the browser. +| +*/ + Cookie::send(); -/** - * Send the final response to the browser and fire the - * final event indicating that the processing for the - * current request is completed. - */ +/* +|-------------------------------------------------------------------------- +| Send The Response To The Browser +|-------------------------------------------------------------------------- +| +| We'll send the response back to the browser here. This method will also +| send all of the response headers to the browser as well as the string +| content of the Response. This should make the view available to the +| browser and show something pretty to the user. +| +*/ + $response->send(); +/* +|-------------------------------------------------------------------------- +| And We're Done! +|-------------------------------------------------------------------------- +| +| Raise the "done" event so extra output can be attached to the response +| This allows the adding of debug toolbars, etc. to the view, or may be +| used to do some kind of logging by the application. +| +*/ + Event::fire('laravel.done'); \ No newline at end of file