Symfony News

New in Symfony 4.1: Deprecated the bundle notation

Tobias Schultze

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

Be trained by Symfony experts - 2018-03-6 Online Europe - 2018-03-6 Online Europe - 2018-03-12 Cologne


About us

What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...

Resources

Find us on Twitter

Find us on Facebook