Autowiring allows to register services in the container with minimal configuration. It automatically resolves the service dependencies based on the constructor's typehints, so it drastically reduces the amount of configuration required to define a service.
By default, the autowiring subsystem only injects dependencies in the constructor of the services. However, even if the constructor injection should always be preferred, sometimes it's convenient to inject dependencies through methods (usually a setter method).
That's why in Symfony 3.3, the autowiring subsystem allows to configure the
setters to use thanks to the new values supported by the
1 2 3 4 5 6 7 8 9 10 11 12
services: app.manager.user: class: AppBundle\Manager\UserManager # to maintain backwards compatibility this value is # automatically transformed into "autowire: ['__construct']" autowire: true # autowire the constructor and all the setters autowire: ['__construct', 'set*'] # autowire only the foo() and bar() methods autowire: ['foo', 'bar']