Check Service Autowiring Using Console Command in Symfony 7

Check Service Autowiring Using Console Command in Symfony 7

The Symfony framework provides numerous pre-built commands that allow the debugging of different parts of an application. Autowiring is a mechanism that automatically injects dependencies into the services, saving you from the hassle of manual configuration. This tutorial explains how to check service autowiring using console command in Symfony 7.

To get all classes and interfaces that you can use as type-hints for autowiring, use the debug:autowiring command without any additional arguments.

php bin/console debug:autowiring

Additionally, you can also provide an argument to filter the list of autowirable services:

php bin/console debug:autowiring serializer

Output example:

The following classes & interfaces can be used as type-hints when autowiring:
 (only showing classes/interfaces matching serializer)

 Symfony\Component\Serializer\Encoder\DecoderInterface - alias:serializer

 Symfony\Component\Serializer\Encoder\EncoderInterface - alias:serializer

 Knows how to get the class discriminator mapping for classes and objects.
 Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolverInterface - alias:serializer.mapping.class_discriminator_resolver

 Returns a {@see ClassMetadataInterface}.
 Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface - alias:serializer.mapping.class_metadata_factory

 Symfony\Component\Serializer\Normalizer\DenormalizerInterface - alias:serializer

 Symfony\Component\Serializer\Normalizer\NormalizerInterface - alias:serializer

 Symfony\Component\Serializer\SerializerInterface - alias:serializer

Leave a Comment

Cancel reply

Your email address will not be published.