Deprecate public usage of service Deprecate public usage of service symfony symfony

Deprecate public usage of service


You can make a "wanna-be-private" service by setting the private attribute to true on the service definition.

yaml: public: true, private: true
php: $definition->setPublic(true)->setPrivate(true);

That will trigger a deprecation notice when getting the service from the container instead of injecting it, so that you can make your service really public: false later.