New in Symfony 4.2: Better autowiring debug
October 29, 2018 • Published by Javier Eguiluz
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
The debug:autowiring
command displays all classes and interfaces that
Symfony developers can use as type-hints for service autowiring. In previous
Symfony versions, it looked like this when looking for something specific (e.g.
the cache
):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
$ ./bin/console debug:autowiring cache
Autowirable Services
====================
The following classes & interfaces can be used as type-hints when autowiring:
(only showing classes/interfaces matching cache)
--------------------------------------------------
Psr\Cache\CacheItemPoolInterface
alias to cache.app
Psr\SimpleCache\CacheInterface
alias to cache.app.simple
Symfony\Component\Cache\Adapter\AdapterInterface
alias to cache.app
Symfony\Contracts\Cache\CacheInterface
alias to cache.app
Symfony\Contracts\Cache\TagAwareCacheInterface
alias to cache.app.taggable
--------------------------------------------------
In Symfony 4.2 we improved this command to make the information easier to
understand. The same search for cache
now looks like this:
As you can see, the description of what the service does now appears above it.
This description is taken from the PHPdoc of the related interface. Also, the
autowire by type and name feature introduced in Symfony 4.2 is displayed
(e.g. CacheInterface $cacheApp
).
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
Thanks!!!