agentsclimarketplace

Symfony ports adapters

Skill aligundogdu/symfony-hexagonal-skill/skills/symfony-ports-adapters

Claude Code plugin that enforces hexagonal architecture (ports & adapters) in Symfony projects — with 10 auto-triggered skills, 2 review agents, and progressive refactoring support for existing codebases.

Install
npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-ports-adapters

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

Symfony ports and adapters — port interfaces, adapter implementations, dependency injection, autowiring, repository interfaces. Triggers on: port, adapter, interface, repository interface, DI, autowiring, dependency injection, services.yaml, binding

SKILL.md

2.9 KB, as published. Nobody here has run it

Symfony Ports & Adapters

You are an expert in the Ports & Adapters pattern within Symfony hexagonal architecture.

When to Activate

  • User needs to define a port (interface) for external dependency
  • User needs to implement an adapter
  • User asks about DI configuration or autowiring
  • User wants to bind an interface to a concrete implementation

Port = Interface in Domain

Ports are interfaces that define contracts for external dependencies. They live in Domain/{Module}/Port/.

Rules

  • One interface per concern (Single Responsibility)
  • Domain-centric naming (not tech-centric): UserRepositoryInterface not DoctrineUserRepository
  • Only domain types in signatures (value objects, entities, primitives)
  • No framework types in port signatures

Common Port Types

Port TypeExample
RepositoryUserRepositoryInterface
External ServicePaymentGatewayInterface
NotificationNotificationServiceInterface
File StorageFileStorageInterface
Event DispatcherEventDispatcherInterface

Template

namespace App\Domain\{Module}\Port;

interface {Concern}Interface
{
    public function methodUsingDomainTypes(ValueObject $param): ?Entity;
}

Adapter = Implementation in Infrastructure

Adapters implement ports using specific technologies. They live in Infrastructure/{Module}/.

Rules

  • Implements exactly one port interface
  • Contains ALL technology-specific code
  • Named with technology prefix: Doctrine{Entity}Repository, Stripe{Payment}Gateway
  • final readonly class when possible

Template

namespace App\Infrastructure\{Module}\Persistence;

use App\Domain\{Module}\Port\{Repository}Interface;

final readonly class Doctrine{Entity}Repository implements {Repository}Interface
{
    public function __construct(
        private EntityManagerInterface $entityManager,
    ) {
    }

    // implement all port methods
}

DI Configuration

# 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\SymfonyMailerAdapter

References

See references/ for detailed guides:

  • port-adapter-examples.md — Full examples for various port types
  • di-configuration.md — Advanced DI configuration patterns

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.