symfony-api-response
Symfony REST API response standard {result, error, extra, status}: thin controllers, #[MapRequestPayload] / #[MapQueryString]…
Symfony hexagonal architecture (ports & adapters) setup for Symfony 6.4 LTS, 7.4 LTS and 8.x: project structure, module scaffolding, layer responsibilities, dependency rules, version compatibility, progressive refactoring of legacy code. Use when: architecture, module, layer,
Claude Code
$ npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture --agent claude-code
Codex
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture -a codex -y
Cursor
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture -a cursor -y
Gemini CLI
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture -a gemini-cli -y
GitHub Copilot
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture -a github-copilot -y
OpenCode
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture -a opencode -y
Windsurf
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture -a windsurf -y
name: symfony-hexagonal-architecture description: "Symfony hexagonal architecture (ports & adapters) setup for Symfony 6.4 LTS, 7.4 LTS and 8.x: project structure, module scaffolding, layer responsibilities, dependency rules, version compatibility, progressive refactoring of legacy code. Use when: architecture, module, layer, hexagonal, scaffold, project structure, directory structure, new project, new module, bounded context, deptrac, Symfony version, upgrade"
You are an expert in Symfony hexagonal architecture (ports & adapters). Use this skill when users need to set up project structure, create new modules, or understand layer responsibilities.
Before generating any code, know the project's Symfony, PHP, Doctrine and PHPUnit versions (the plugin's SessionStart hook prints them; otherwise read `composer.lock`). Then follow `references/version-compatibility.md`:
Presentation → Application → Domain ← Infrastructure
Infrastructure depends on Domain (implements ports), but Domain NEVER depends on Infrastructure.
Every module follows this structure under `src/`:
Domain/{Module}/
├── Entity/ # Aggregates and entities (pure PHP)
├── ValueObject/ # Immutable value objects
├── Event/ # Domain events (past-tense)
├── Exception/ # Domain-specific exceptions
├── Port/ # Interfaces for external dependencies (write + read ports)
└── ReadModel/ # (optional) Plain read-side view objects returned by read ports
Application/{Module}/
├── Command/ # Write operations (final readonly) + handlers
├── Query/ # Read operations (final readonly) + handlers
├── DTO/ # Data transfer objects
└── EventHandler/ # Domain event handlers (side-effects)
Infrastructure/{Module}/
├── Persistence/ # Doctrine repositories, Mapping/*.orm.xml
├── Security/ # Voters, user providers
├── Messaging/ # Transport adapters, middleware
└── ExternalService/ # HTTP clients, third-party APIs
Presentation/{Module}/
├── API/ # REST controllers (+ Request/ DTOs)
├── CLI/ # Console commands
└── GraphQL/ # GraphQL resolvers/typesShared code lives in a `Shared` module per layer (`Domain/Shared/ValueObject/Money.php`, `Presentation/Shared/Bus/QueryBus.php`, ...).
When working on an existing project that doesn't follow hexagonal architecture:
Before writing any code, check:
- Is src/ organized by layer (Domain/, Application/, etc.) or by traditional Symfony (Controller/, Entity/, Repository/)? - Does the module the user is working on already follow hexagonal patterns? - Are there Doctrine annotations/attributes directly on entities? - Which Symfony / Doctrine versions are installed (affects what the refactor can use)?
When the user requests a feature/change in a non-hexagonal module, ALWAYS ask:
> "Bu modül (`{Module}`) şu anda hexagonal yapıda değil. Şu seçeneklerden birini tercih edebilirsiniz: > 1. **Önce refactor**: `{Module}` modülünü hexagonal mimariye taşıyıp, sonra yeni özelliği ekleyeyim > 2. **Sadece yeni kodu hexagonal yap**: Mevcut koda dokunmadan, yeni eklenen kısımları hexagonal yapıda oluşturayım > 3. **Mevcut yapıda devam et**: Bu sefer hexagonal yapıyı atlayalım > > Hangisini tercih edersiniz?"
Migrate one layer at a time, in this order:
1. **Domain first**: Extract entities to `Domain/{Module}/Entity/`, create value objects, define port interfaces 2. **Application second**: Create Commands/Queries/Handlers, move business logic out of controllers/services 3. **Infrastructure third**: Move Doctrine repositories to `Infrastructure/{Module}/Persistence/`, move mapping from attributes/annotations to XML 4. **Presentation last**: Thin out controllers, add `ApiResponseTrait` + `#[MapRequestPayload]` DTOs, apply `#[IsGranted]`
After each layer, verify the code still works (tests + `doctrine:schema:validate`) before moving to the next.
Legacy projects on Doctrine annotations (`@ORM\...`) cannot upgrade to ORM 3 anyway: moving the mapping to XML during the Infrastructure step unblocks that upgrade too.
When user asks to create a new module, generate ALL directories and base files:
1. Create directory structure (all 4 layers) 2. Create the port interfaces in `Domain/{Module}/Port/` 3. Create the repository adapter + XML mapping in `Infrastructure/{Module}/Persistence/` 4. Register the mapping directory in `doctrine.yaml` and bind ports to adapters in `services.yaml` 5. Suggest initial entities, commands, and queries based on the module purpose
1. **Domain purity**: No `use Symfony\
A Claude Code plugin that enforces hexagonal architecture (ports & adapters) in Symfony projects. Works with both new projects (full scaffolding) and existing projects (progressive, module-by-module refactoring).
Symfony REST API response standard {result, error, extra, status}: thin controllers, #[MapRequestPayload] / #[MapQueryString]…
Symfony CQRS with Messenger: commands, queries, handlers, command.bus / query.bus / event.bus configuration, typed bus wrappers,…
Doctrine persistence for Symfony hexagonal architecture (ORM 2.x/3.x, DBAL 3/4, DoctrineBundle 2/3): repository adapters, XML…
Symfony DDD domain modeling in pure PHP: entities, aggregates, value objects, domain events, domain exceptions, ID generation…
Symfony Messenger async processing and Symfony Scheduler instead of cron: transports, routing (#[AsMessage] 7.2+), retry with…
Symfony ports and adapters: port interfaces in Domain, adapter implementations in Infrastructure, dependency injection,…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.