03.12.2015 Views

laravel4cookbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

File-Based CMS 346<br />

.<br />

This was extracted from app/routes.php.<br />

Finally, we add the routes which will allow us to access these pages. With all this in place, we can<br />

work on displaying the website content.<br />

Displaying Content<br />

Aside from our admin pages, we need to be able to catch the all requests, and route them to a single<br />

controller/action. We do this by appending the following route to the routes.php file:<br />

1 Route::any("{all}", [<br />

2 "as" => "index/index",<br />

3 "uses" => "IndexController@indexAction"<br />

4 ])->where("all", ".*");<br />

.<br />

This was extracted from app/routes.php.<br />

We pass all route information to a named parameter ({all}), which will be mapped to the IndexController::indexAction()<br />

method. We also need to specify the regular expression with which the route<br />

data should be matched. With ”.*” we’re telling Laravel to match absolutely anything. This is why<br />

this route needs to come right at the end of the app/routes.php file.<br />

1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!