Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Add Route Annotation : explicit_defaults#28633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Allows generator to add default values to generated URLin order to get a canonical one
ro0NL commentedSep 29, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
what about a new path syntax to do this:
|
nicolas-grekas commentedSep 29, 2018
I like@ro0NL's idea to deal with this at the param syntax level. |
chs2 commentedSep 29, 2018
My original idea was to have a canonical URL generated. Having the option on the parameter level gives more flexibility but IMO defeats the purpose of the canonical URL. (BTW, the next step I had in mind was having the Router sending a Redirect when it matches a route on a non-canonical form.) |
ro0NL commentedSep 29, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
we can debate if redirecting non-canonical to canonical URLs is something that belongs to core 🤔 if so, that might also be triggered by e.g. |
nicolas-grekas commentedSep 29, 2018
The generated URL is already a canonical one to me. I get you'd like it to have the suffix in it instead. It's not about canonical 1/0 to me, but about suffix 1/0, isn't it? |
nicolas-grekas commentedOct 20, 2018
@chs2 WDYT about these proposals? Would you like to implement it? |
chs2 commentedOct 21, 2018
I'd like to but I can't get my head around the param syntax especially with the XML/XSD. |
ro0NL commentedOct 22, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@chs2 i dont think we need canonical:true|false, as@nicolas-grekas mentioned each configured route is/should be already a canonical one. So the options are:
news_export:path:'/exports/news.{_format}'defaults:_format:xml
news_export_non_canonical:path:'/export/news'controller:Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectActiondefaults:route:news_export_xmlnews_export_xml:path:'/exports/news.xml' These are explicit configurations to show we dont need If we look at option 2, we see our missing step: it cant specify the That's what we should solve by the proposed news_export_non_canonical:path:'/export/news'controller:Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectActiondefaults:route:news_exportnews_export:path:'/exports/news.{!_format}'defaults:_format:xml Due |
Allows generator to add default values to generated URL
in order to get a canonical one
If a route has a parameter with default value when it gets generated this parameter is not included
$uriis/exports/newswhich is identical, from the router point of view, to/export/news.xml.URIs should be unique to avoid duplicate content, which is bad for SEO.
Though it is possible to always add default value to parameters (
$router -> generate('news_export', ['_format' => 'xml', ])), the added "explicit_defaults" ensures the route will always generated to a canonical form.