Closed
Description
Q | A |
---|---|
Bug report? | no |
Feature request? | no |
BC Break report? | no |
RFC? | yes |
Symfony version | 4.1 |
There are currently three ways to reference controllers in symfony:
- service:method, e.g.
_controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController:redirectAction
- class::method, e.g.
_controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
- bundle:controller:action, e.g.
_controller: FrameworkBundle:Redirect:redirect
Having many ways to do the same thing just confuses people. And the old bundle:controller:action notation does not fit anymore for several reasons:
- bundle:controller:action does not work with bundle-less apps obviously
- Symfony 4 is advocating defining controllers as services. Symfony framework bundle itself also defines controllers as services since [Bridge\Doctrine][FrameworkBundle] Deprecate some remaining uses of ContainerAwareTrait #24409. So service:method would work as well.
- it causes overhead for parsing different notations and workarounds like Parse the _controller format in sub-requests #23013
- bundle:controller:action also doesn't work when using invokable controllers ([FrameworkBundle][DX] ControllerNameParser does not handle invokable controllers #22338)
- bundle:controller:action assumes a certain namespace structure and *Action suffix for controllers, see https://github.com/symfony/symfony/blob/master/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php#L70-L73 This is not fit the new documented best practice to not use the *Action suffix anymore, see https://symfony.com/doc/current/routing.html which does not use it.
- when using annotations for routes, you don't care about these things anyway
For these reasons I think we should deprecate this notation.