-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Use the controller's FQCN as default internal route name, instead of app_controller_method
#52945
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I dislike convention-based naming, like ZF1 used to do everywhere. However, this seems like indeed an unnecessary BC break, which is also hard to discover. I feel like the risk outweighs the benefits. I explicitly set all my routes with FQCN like this: |
I agree with Anna of. Another idea: |
I agree with Anna too. Another idea: |
Thank you for this suggestion. |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Description
Currently, when a route is defined without a
name
, Symfony creates a default name in the form:app_<controller>_<method>
(seeAttributeClassLoader::getDefaultRouteName()
)I'm suggesting to change this to the controller's FQCN:
App\Controller\MyController
.In other words: Change the newly created FQCN alias (introduced in #50084) to be the actual name:
name: 'foo'
foo
alias:
App\Controller\MyController
name
is not setapp_my__invoke
alias:
App\Controller\MyController
App\Controller\MyController
alias: none
Reason: Twig!
The idea of #49981 was to get rid of manually creating a
name
, and always just use the FQCN. But in Twig... doesn't work, since
app.current_route
isapp_my__invoke
.Although I doubt that many people rely on the current default route (the syntax isn't even documented properly, see https://symfony.com/doc/current/routing.html#generating-urls), changing it would still be a BC break.
As a next step, the docs could be changed to (I could take care of that):
name
from most code samples, and explain it as a solution for special cases only.Example
No response
The text was updated successfully, but these errors were encountered: