symfony-api-response
Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API,…
Symfony hexagonal architecture setup — project structure, module scaffolding, layer responsibilities, dependency rules. Triggers on: architecture, module, layer, hexagonal, scaffold, project structure, directory structure, new project, new module
$ npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-hexagonal-architecture --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/symfony-hexagonal-architectureContext preview
The summary Claude sees to decide when to auto-load this skill.
Symfony hexagonal architecture setup — project structure, module scaffolding, layer responsibilities, dependency rules. Triggers on: architecture, module, layer, hexagonal, scaffold, project structure, directory structure, new project, new module
description: "Symfony hexagonal architecture setup — project structure, module scaffolding, layer responsibilities, dependency rules. Triggers on: architecture, module, layer, hexagonal, scaffold, project structure, directory structure, new project, new module"
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.
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
Application/{Module}/
├── Command/ # Write operations (final readonly)
├── Query/ # Read operations (final readonly)
├── DTO/ # Data transfer objects
└── EventHandler/ # Domain event handlers
Infrastructure/{Module}/
├── Persistence/ # Doctrine repositories, mappings
├── Messaging/ # Messenger handlers, transports
└── ExternalService/ # HTTP clients, third-party APIs
Presentation/{Module}/
├── API/ # REST controllers
├── CLI/ # Console commands
└── GraphQL/ # GraphQL resolvers/typesWhen 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 directly on entities?
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/`, extract mappings 4. **Presentation last**: Thin out controllers, add `ApiResponseTrait`, apply `#[IsGranted]`
After each layer, verify the code still works before moving to the next.
When user asks to create a new module, generate ALL directories and base files:
1. Create directory structure (all 4 layers) 2. Create a sample port interface in `Domain/{Module}/Port/` 3. Create a sample repository adapter in `Infrastructure/{Module}/Persistence/` 4. Bind the port to adapter in `services.yaml` 5. Suggest initial entities, commands, and queries based on the module purpose
1. **Domain purity**: No `use Symfony\...` or `use Doctrine\...` in any Domain file 2. **Port-first**: Define the interface before the implementation 3. **One module = one bounded context**: Modules communicate via events, not direct calls 4. **Namespace convention**: `App\Domain\{Module}\...`, `App\Application\{Module}\...`, etc.
See `references/` for detailed guides:
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 API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API,…
Symfony CQRS command/query handlers — commands, queries, handlers, bus configuration, use cases. Triggers on: command, query, handler, CQRS, bus, use case,…
Symfony Doctrine persistence — repository adapters, entity mapping, migrations, transactions, database patterns. Triggers on: doctrine, repository,…
Symfony domain modeling — entities, value objects, domain events, aggregates, domain exceptions. Triggers on: entity, value object, domain event, aggregate,…
Symfony Messenger async processing — message queues, retry strategies, failure transport, Symfony Scheduler, idempotency patterns, background jobs. Triggers…
Symfony ports and adapters — port interfaces, adapter implementations, dependency injection, autowiring, repository interfaces. Triggers on: port, adapter,…