Skip to content

Deprecated

Mauro Gadaleta edited this page Mar 10, 2017 · 1 revision

Deprecating Services

Once you have decided to deprecate the use of a service (because it is outdated or you decided not to maintain it anymore), you can deprecate its definition:

JS
let definition = container.register('mailer', Mailer)
definition.deprecated = 'The mailer service is deprecated since 3.4 and will be removed in 4.0'
YAML
mailer:
    class: ./Mailer
    deprecated: 'The mailer service is deprecated since 3.4 and will be removed in 4.0'

Now, every time this service is used, a deprecation warning is triggered, advising you to stop or to change the usage of that service.

It is strongly recommended that you define a custom message because there is no generic message provided. A good message informs when this service was deprecated, until when it will be maintained and the alternative services to use (if any).