/symfony-hexagonal:symfony-hexagonal-architecturefrom symfony-hexagonal
Sets up Symfony projects with hexagonal architecture (ports & adapters): project structure, module scaffolding, layer responsibilities, dependency rules, version compatibility, and legacy refactoring.
Ships in symfony-hexagonal. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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:
DeduplicateStamp, 7.4 #[ExtendsValidationFor], PHP 8.4 private(set), ...) only when the detected versions allow itRequest::get(), constraint option arrays, XML service config)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/types
Shared 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:
- Önce refactor:
{Module}modülünü hexagonal mimariye taşıyıp, sonra yeni özelliği ekleyeyim- Sadece yeni kodu hexagonal yap: Mevcut koda dokunmadan, yeni eklenen kısımları hexagonal yapıda oluşturayım
- Mevcut yapıda devam et: Bu sefer hexagonal yapıyı atlayalım
Hangisini tercih edersiniz?"
Migrate one layer at a time, in this order:
Domain/{Module}/Entity/, create value objects, define port interfacesInfrastructure/{Module}/Persistence/, move mapping from attributes/annotations to XMLApiResponseTrait + #[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:
Domain/{Module}/Port/Infrastructure/{Module}/Persistence/doctrine.yaml and bind ports to adapters in services.yamluse Symfony\..., use Doctrine\... or use Psr\... in any Domain file, and no framework attributes (#[ORM\...], #[Assert\...], #[AsMessage])App\Domain\{Module}\..., App\Application\{Module}\..., etc.references/dependency-rules.md)See references/ for detailed guides:
version-compatibility.md - Symfony / PHP / Doctrine / PHPUnit support matrix, per-feature minimum versions and fallbacksdirectory-structure.md - Full directory layout with file exampleslayer-responsibilities.md - What belongs in each layerdependency-rules.md - Import rules, deptrac and PHPStan enforcementWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub aligundogdu/symfony-hexagonal-skill --plugin symfony-hexagonal10 skills in this plugin
/symfony-api-responseSymfony REST API response standard {result, error, extra, status}: thin controllers, #[MapRequestPayload] / #[MapQueryString] request DTOs, ApiResponseTrait, exception subscriber that unwraps Messenger HandlerFailedException, validation error format, debug mode. Use when: API, endpoint, controller, response, error handling, JSON, REST, API response, exception subscriber, HTTP, request DTO/symfony-cqrs-handlersSymfony CQRS with Messenger: commands, queries, handlers, command.bus / query.bus / event.bus configuration, typed bus wrappers, HandlerFailedException unwrapping, read ports and pagination, use cases. Works on Symfony 6.4, 7.x, 8.x. Use when: command, query, handler, CQRS, bus, use case, command handler, query handler, message bus, HandleTrait, HandledStamp/symfony-doctrine-persistenceDoctrine persistence for Symfony hexagonal architecture (ORM 2.x/3.x, DBAL 3/4, DoctrineBundle 2/3): repository adapters, XML mapping in Infrastructure, embeddables, enums, custom DBAL types, native lazy objects, migrations, transactions, read models with DBAL QueryBuilder, strict no-native-SQL rule. Use when: doctrine, repository, persistence, database, mapping, migration, ORM, entity manager, DBAL, transaction, query builder, pagination/symfony-domain-modelingSymfony DDD domain modeling in pure PHP: entities, aggregates, value objects, domain events, domain exceptions, ID generation ports, PHP 8.2-8.5 modeling features (readonly, private(set), clone with). Use when: entity, value object, domain event, aggregate, domain exception, domain model, domain logic, business rule, invariant, enum status/symfony-messenger-asyncSymfony Messenger async processing and Symfony Scheduler instead of cron: transports, routing (#[AsMessage] 7.2+), retry with backoff and jitter, failure transport, idempotency keys, DeduplicateStamp (7.3+), workers, supervisor, scheduled commands with stateful/locked schedules. Use when: messenger, async, queue, retry, scheduler, background job, worker, transport, message queue, cron, scheduled task, idempotency, deduplication/symfony-ports-adaptersSymfony ports and adapters: port interfaces in Domain, adapter implementations in Infrastructure, dependency injection, autowiring, services.yaml aliases, #[AsAlias], environment-specific and decorated adapters, in-memory test adapters. Use when: port, adapter, interface, repository interface, DI, autowiring, dependency injection, services.yaml, binding, decorator, AsAliasOther plugins' skills for the same job