Contributed by
Tobias Schultze
in #26085.
In modern Symfony applications, it's no longer recommended to organize your business logic using bundles. However, it was still possible to use the "bundle notation" for example when defining routes:
1 2 3 4 | bundle_controller:
path: /
defaults:
_controller: FrameworkBundle:Redirect:redirect
|
In order to keep simplifying things and to keep replacing "Symfony concepts" by standard PHP features, in Symfony 4.1 we've deprecated the bundle notation in favor of the regular PHP namespace notation:
1 2 3 4 | bundle_controller:
path: /
defaults:
_controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
|
While working on this, we noticed a related inconsistency that could be fixed.
When defining controllers as services, you must use a single colon (:
)
instead of a double colon (::
) to separate the service ID and the method name:
1 2 3 4 | service_controller:
path: /
defaults:
_controller: app.my_controller:myAction
|
In other parts of Symfony you always use a double colon (::
) to separate
classes and method names, so this difference is confusing and it complicates the
learning curve for no real benefit. That's why in Symfony 4.1 you can always use
a double colon to separate the method names, even for controllers as services:
1 2 3 4 | service_controller:
path: /
defaults:
_controller: app.my_controller::myAction
|
What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...