Joost van Driel Renan
Contributed by Joost van Driel and Renan in #29968

Deprecations are the key of our backward compatibility promise, which ensures smooth upgrades of your projects between minor versions (e.g. from 4.0 to 4.x). In order to provide a great developer experience, your own Symfony apps can also deprecate services, deprecate config options and even deprecate Twig templates, blocks and macros.

In Symfony 4.3, you'll also be able to deprecate service aliases. When an alias should no longer be used in your application, define it as deprecated with the deprecated configuration option:

1
2
3
4
5
6
7
# config/services.yaml
services:
    # ...

    app.mailer:
        alias: App\Mail\PhpMailer
        deprecated: ~

If this alias is used anywhere in your app, you'll see a generic error message. If you prefer to customize that message, define it using the deprecated option (the only requirement is that the message must include the %alias_id% placeholder):

1
2
3
4
5
6
7
# config/services.yaml
services:
    # ...

    app.mailer:
        alias: App\Mail\PhpMailer
        deprecated: 'The "%alias_id%" service alias is deprecated.'
Published in #Living on the edge