---
name: "symfony-dependency-injection-container"
description: "Architect enterprise PHP backends using Symfony's compiled dependency injection container."
metadata:
  author: "Fabien Potencier"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "configure symfony autowiring"
  - "tag services symfony"
  - "symfony compiler pass"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Symfony Dependency Injection & Service Container

Configures Symfony Service Container: defining services in YAML/PHP, constructor autowiring, tagged services (e.g. tag: 'twig.extension'), service subscribers, compiler passes, and factory definitions.

## When to Invoke
Invoke this skill whenever you need to:
- configure symfony autowiring
- tag services symfony
- symfony compiler pass

## Execution SOP & Rules
1. Enable autowiring in services.yaml: services: _defaults: autowire: true, autoconfigure: true.
2. Inject interface dependencies in constructors: public function __construct(LoggerInterface $logger).
3. Bind named arguments: services: _defaults: bind: $stripeKey: '%env(STRIPE_SECRET_KEY)%'.
4. Verify container compilation: php bin/console debug:container to inspect registered services.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
