Routing
In the shortest terms, routing is about linking the controllers with URLs entered in browser. Todays modern web applications need nice URLs. This means moving away from URLs like /index.php?product_id=23
to something like /catalog/product/t-shirt
. This is where routing comes in to play.
Symfony has a powerful routing mechanism that enables us to do the following:
- Create complex routes which map to controllers
- Generate URLs inside templates
- Generate URLs inside controllers
- Load routing resources from various locations
The way routing works in Symfony is that all of the requests come through app.php
. Then, the Symfony core asks the router to inspect the request. The router then matches the incoming URL to a specific route and returns information ...
Get Modular Programming with PHP 7 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.