Symfony Ports Adapters logo

Symfony Ports Adapters

Community
aligundogdu
symfony-ports-adapters

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

Overview

Publisheraligundogdu
Repositorysymfony-hexagonal-skill
Skill namesymfony-ports-adapters
Stars
35
Forks
4
Bundled files
2
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by aligundogdu on GitHub. Read the source before you install it.

Installation

Install the Symfony Ports Adapters AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/aligundogdu/symfony-hexagonal-skill/tree/main/skills/symfony-ports-adapters
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/aligundogdu/symfony-hexagonal-skill.git /tmp/symfony-hexagonal-skill
mkdir -p .claude/skills
cp -r /tmp/symfony-hexagonal-skill/skills/symfony-ports-adapters .claude/skills/symfony-ports-adapters
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Symfony Ports Adapters in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Symfony Ports Adapters on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Symfony Ports Adapters is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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

Version Notes

FeatureRequiresFallback
alias: in services.yamlall versions-
when@test: / when@dev: blocksSymfony 5.3services_test.yaml
#[AsAlias(PortInterface::class)] on the adapterSymfony 6.3YAML alias
#[AsAlias(..., when: 'test')]Symfony 7.3when@test: YAML block
#[AsDecorator(decorates: ...)]Symfony 6.1decorates: in YAML
Repeatable #[AsDecorator]Symfony 7.4one decorator per class

Default to YAML aliases: they work on every version and keep all bindings visible in one file.

Port = Interface in Domain

Ports are interfaces that define contracts for external dependencies. They live in Domain/{Module}/Port/ (shared ones in Domain/Shared/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, read models, scalars)
  • No framework types in port signatures (Request, Collection, UploadedFile, Uuid, ...)
  • IDs, clocks and password hashing are ports too

Common Port Types

Port TypeExample
Repository (write)UserRepositoryInterface
Read repositoryUserReadRepositoryInterface
External ServicePaymentGatewayInterface
NotificationNotificationServiceInterface
File StorageFileStorageInterface
IdentityIdGeneratorInterface
SecurityPasswordHasherInterface

Template

php
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};
}

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
  • Translates technology exceptions into domain exceptions where callers need to react

Template

php
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
}

DI Configuration

yaml
# 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

Attribute alternative (Symfony 6.3+), on the adapter:

php
use Symfony\Component\DependencyInjection\Attribute\AsAlias;

#[AsAlias(UserRepositoryInterface::class)]
final readonly class DoctrineUserRepository implements UserRepositoryInterface { /* ... */ }

References

See references/ for detailed guides:

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

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Symfony Ports Adapters AI skill do?

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

Why use Symfony Ports Adapters on TypingMind?

Because you install it once and use it with any model. Symfony Ports Adapters is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Symfony Ports Adapters in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/aligundogdu/symfony-hexagonal-skill/tree/main/skills/symfony-ports-adapters. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Symfony Ports Adapters?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Symfony Ports Adapters?

As many as you like. As long as a model supports skills, you can use Symfony Ports Adapters with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Symfony Ports Adapters AI skill free?

It is published on GitHub by aligundogdu. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇