symfony-api-response
Symfony REST API response standard {result, error, extra, status}: thin controllers, #[MapRequestPayload] / #[MapQueryString]…
Symfony 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,
Claude Code
$ npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters --agent claude-code
Codex
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters -a codex -y
Cursor
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters -a cursor -y
Gemini CLI
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters -a gemini-cli -y
GitHub Copilot
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters -a github-copilot -y
OpenCode
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters -a opencode -y
Windsurf
$ npx skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters -a windsurf -y
name: symfony-ports-adapters description: "Symfony 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, AsAlias"
You are an expert in the Ports & Adapters pattern within Symfony hexagonal architecture.
| Feature | Requires | Fallback | |---|---|---| | `alias:` in `services.yaml` | all versions | - | | `when@test:` / `when@dev:` blocks | Symfony 5.3 | `services_test.yaml` | | `#[AsAlias(PortInterface::class)]` on the adapter | Symfony 6.3 | YAML alias | | `#[AsAlias(..., when: 'test')]` | Symfony 7.3 | `when@test:` YAML block | | `#[AsDecorator(decorates: ...)]` | Symfony 6.1 | `decorates:` in YAML | | Repeatable `#[AsDecorator]` | Symfony 7.4 | one decorator per class |
Default to YAML aliases: they work on every version and keep all bindings visible in one file.
Ports are interfaces that define contracts for external dependencies. They live in `Domain/{Module}/Port/` (shared ones in `Domain/Shared/Port/`).
| Port Type | Example | |-----------|---------| | Repository (write) | `UserRepositoryInterface` | | Read repository | `UserReadRepositoryInterface` | | External Service | `PaymentGatewayInterface` | | Notification | `NotificationServiceInterface` | | File Storage | `FileStorageInterface` | | Identity | `IdGeneratorInterface` | | Security | `PasswordHasherInterface` |
namespace App\Domain\{Module}\Port;
use App\Domain\{Module}\Entity\{Entity};
use App\Domain\{Module}\ValueObject\{Entity}Id;
interface {Entity}RepositoryInterface
{
public function save({Entity} $entity): void;
public function findById({Entity}Id $id): ?{Entity};
}Adapters implement ports using specific technologies. They live in `Infrastructure/{Module}/`.
namespace App\Infrastructure\{Module}\Persistence;
use App\Domain\{Module}\Port\{Entity}RepositoryInterface;
use Doctrine\ORM\EntityManagerInterface;
final readonly class Doctrine{Entity}Repository implements {Entity}RepositoryInterface
{
public function __construct(
private EntityManagerInterface $entityManager,
) {
}
// implement all port methods
}# config/services.yaml
services:
# Bind ports to adapters
App\Domain\User\Port\UserRepositoryInterface:
alias: App\Infrastructure\User\Persistence\DoctrineUserRepository
App\Domain\Payment\Port\PaymentGatewayInterface:
alias: App\Infrastructure\Payment\ExternalService\StripePaymentGateway
App\Domain\Notification\Port\NotificationServiceInterface:
alias: App\Infrastructure\Notification\ExternalService\SymfonyMailerAdapterAttribute alternative (Symfony 6.3+), on the adapter:
use Symfony\Component\DependencyInjection\Attribute\AsAlias;
#[AsAlias(UserRepositoryInterface::class)]
final readonly class DoctrineUserRepository implements UserRepositoryInterface { /* ... */ }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 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 hexagonal architecture (ports & adapters) setup for Symfony 6.4 LTS, 7.4 LTS and 8.x: project structure, module…
Symfony Messenger async processing and Symfony Scheduler instead of cron: transports, routing (#[AsMessage] 7.2+), retry with…
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.