The symfony routing system is one of the killer features of the framework.
<p>Please have a look on <php echo link_to('our products', 'product/index') ?>.</p>
Indicate in your template which module/action
you want and then let routing.yml
do all the job.
You can use the default rule:
default:
url: /:module/:action/*
Or add a dedicated one:
product_list:
url: /our-products
param: { module: product, action: index }
Clear your cache and all the related links and uri will be modified, all over the application.
It feels like magic, but it has a cost.
Each time the url request product/index
is found in a template, symfony has to scan all the rules defined in routing.yml
and guess which one can handle this request.
The default rule ? An other one ?
This search is done for all the links...
If your project have many pages and many routing rules, you can speed up your application by using rule labels instead of a module/action pairs in your templates:
<p>Please have a look on <php echo link_to('our products', '@product_list') ?>.</p>
This solution will speed up the routing, but the drawback is that internal links can become a little less self-evident.
It's up to you.
Read the related symfony documentation
Powered by jQuery UI and symfony. Symfony Check
The content this site is published under a Creative Commons License. Some parts of the content are a remix of the official symfony documentation.