Symfony News

New in Symfony 3.4: Deprecated bundle inheritance

Fabien Potencier

Contributed by
Fabien Potencier
in #24160.

One of the biggest changes of the upcoming Symfony 4 version is the removal of bundles to manage the application code. Bundles will still exist as third-party plugins installed in vendor/, but your own code will live by default in the src/ directory and it will use plain PHP namespaces instead of bundles.

In Symfony 3.4 we worked towards simplifying bundles even more. That's why we deprecated bundle inheritance and we'll remove it in Symfony 4.0. This inheritance mechanism was traditionally used to override some templates, controllers and other elements of third-party bundles. In Symfony 4.0 you'll need to use alternative solutions to override those elements:

  • Controllers: define a route with the same path as the controller you want to override and implement your own logic.
  • Templates: use Twig namespaces to define your own templates using the same namespace as the bundle you want to customize.
  • Routing: don't load the bundle routes or apply the same technique as controllers.
  • Services and Configuration: use compiler passes or service decoration.
  • Entities: not possible unless the bundle provides a mapped superclass.
  • Forms: use form extensions.
  • Validation: not possible unless the bundle provides validation groups.
  • Translations: not related to bundle inheritance; just override the right translation domain.

Be trained by Symfony experts - 2017-10-9 Paris - 2017-10-9 Paris - 2017-10-9 Lyon


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