
Skill
symfony-service-inspection
debug Symfony dependency injection and wiring
Published by Symfony Updated Aug 31
Covers PHP Architecture Debugging
Description
Diagnose a Symfony dependency-injection or wiring problem, service not found, wrong implementation injected, an autoconfigured tag not applied, or a factory/decorator not doing what you expect. Use for container/config bugs, not runtime request errors (profiler), log trends (log investigation), or a missing PHP extension breaking the tool itself (php environment check).
SKILL.md
Service inspection
Reads the compiled DI container through Mate's CLI, from the dumped *DebugContainer.xml. Two tools:
symfony-services(optquery,tag,limit):queryis a case-insensitive partial match on service id OR class;tagis an exact tag name. Returns{services: {id => class}, count, truncated}.countis the number of matches before the cut,truncatedsays whetherlimit(default 100) hid some. Narrow the filter rather than raisinglimit.symfony-service-detail --id=<exact id>: full detail for one service,{id, class, tags, calls, factory?}. The id must be exact.
Both commands accept --format: json to parse the result, toon (when helgesverre/toon is installed) for the smallest context footprint. The service map can be large, so filter it rather than dumping it wide.
Workflow
- Locate candidates with
symfony-services, filtered. Never dump the whole container.- By class or interface:
vendor/bin/mate tools:call symfony-services --query=MailerInterface - By id fragment:
--query=app.handler - By tag, to see who participates in a hook:
vendor/bin/mate tools:call symfony-services --tag=kernel.event_listener
- By class or interface:
- Take the exact id from that map and read it:
vendor/bin/mate tools:call symfony-service-detail --id=App\\Mailer\\Mailer. - Interpret against the symptom below.
Reading
- Wrong implementation injected: query the interface. Every id mapping to a class is a candidate. The one wired in is usually the alias whose id equals the interface FQCN. Aliases are resolved for you: asking for the alias id returns the target's class, tags, and calls, so
detailon the interface id shows the concrete class that actually gets injected. - Tag not applied (listener/subscriber/extension silent):
detailthe service and checktags. If the expected tag is absent, autoconfiguration did not fire, usually because the class does not implement the expected interface/attribute, orautoconfigureis off. Each tag entry carries its attributes (event,priority,method, ...); a listener bound to the wrongeventorpriorityis a common cause. - Constructor/factory surprise:
factory(present only when set) isClass::method, telling you the object is built by a factory, notnew.callslists setter-injection method names invoked after construction. A dependency that is null at runtime is often a missing setter call here.
Failure paths
symfony-service-detailerrors "Service ... not found": the id is not exact. Ids are case-sensitive and a leading dot is stripped (.inneris stored asinner). Re-runsymfony-serviceswith a fragment to copy the real id. Note a service can exist yet be private; it still appears here.- Either tool errors "No compiled container found": the dump only exists after the container is compiled. Warm it (
bin/console cache:warmup, or just boot the app once) in the environment you are inspecting, then retry. An emptyservicesmap withcount: 0is a different answer and means the filter matched nothing. If a warm cache still yields nothing, the parse itself may be failing because the runtime lackssimplexml; confirm the environment with php environment check. - Reads the first of dev/test/prod it finds. If you are chasing an env-specific binding, make sure that environment's container has been compiled, otherwise you are reading dev.
More skills from the ai repository
View all 4 skillsSkillTagsUpdated