You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when a route is defined without a name, Symfony creates a default name in the form: app_<controller>_<method> (see AttributeClassLoader::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:
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: #[Route('/', name: self::class)] to avoid managing arbitrary strings.
Another idea: {% if 'App\Controller\MyController' == app.current_route %} could be turned into something like {% if is_current_route('App\Controller\MyController') %} or similar, WDYT?
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: