Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add an option to debug:container CLI command to see service usage #37413

Closed
@matks

Description

@matks

Description

Quite often, I find myself in a situation where I need to update an existing Service in my Symfony application and I need to find "all the services relying on it" to update them.

So I have service app.category.data_provider and I want to see all other services that are being injected this instance.

So I would like this to happen:

$ php bin/console debug:container app.category.data_provider --show-usage

Information for Service "app.category.data_provider"
======================================================================

 ---------------- -----------------------------------------------------------------------
  Option           Value
 ---------------- -----------------------------------------------------------------------
  Service ID    app.category.data_provider
  Class            App\Category\Data_provider
  Tags             -
  Public           yes
  Synthetic     no
  Lazy             no
  Shared         yes
  Abstract       no
  Autowired        no
  Autoconfigured   no
  Used by:              app.category.data_handler, app.product.registrar
 ---------------- -----------------------------------------------------------------------

I think about making it optional because I expect the operation to be resources consuming, so no need to clutter the default debug:container Command with it.

I have an idea about how to do it, but it's an expensive one: go through the full container graph and look for all declarations 😅 . I'm checking whether or not the idea is good by opening this issue before diving into the code and submitting a PR.

If the application is leveraging the power of auto-wiring and strict typing, the "find usage" search can be done by any good IDE. However on legacy applications, auto-wiring and strict typing are not that common ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions