How to create and load services via autowiring

There are times when we only care about quick and dirty prototyping for a service. We don't know the service details and it is an ongoing job, which means that the service parameters might change over and over again.

It makes the service definition a little tricky. Imagine how many times we would have to refactor the service until we reach the final structure. Luckily, we can create a service with minimal configuration. Introduced in Symfony 2.8, with autowiring, we can ignore details of the service definition and let Symfony find and handle any dependency for us:

services:
   som_service:
      class: some_class
      autowire:true

You can read more about it here:

https://symfony.com/doc/current/components/dependency_injection/autowiring.html ...

Get Mastering Symfony now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.