Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.
中文简介正在准备中。当前显示原文说明。
Hexagonal Architecture (Ports & Adapters) knowledge base. Provides patterns, antipatterns, and PHP-specific guidelines for Hexagonal Architecture audits.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
Quick reference for Hexagonal Architecture (Ports & Adapters) patterns and PHP implementation guidelines.
┌─────────────────────────────┐
│ PRIMARY ACTORS │
│ (Users, External Apps) │
└──────────────┬──────────────┘
│
┌──────────────▼──────────────┐
│ DRIVING ADAPTERS │
│ (Controllers, CLI, GUI, │
│ Message Consumers) │
└──────────────┬──────────────┘
│
┌─────────────────────────▼─────────────────────────┐
│ DRIVING PORTS │
│ (Input Interfaces) │
└─────────────────────────┬─────────────────────────┘
│
┌─────────────────────────▼─────────────────────────┐
│ │
│ APPLICATION CORE │
│ ┌─────────────────────────────────┐ │
│ │ APPLICATION LAYER │ │
│ │ (Use Cases, Services) │ │
│ └─────────────────┬───────────────┘ │
│ │ │
│ ┌─────────────────▼───────────────┐ │
│ │ DOMAIN LAYER │ │
│ │ (Entities, Value Objects, │ │
│ │ Domain Services) │ │
│ └─────────────────────────────────┘ │
│ │
└─────────────────────────┬─────────────────────────┘
│
┌─────────────────────────▼─────────────────────────┐
│ DRIVEN PORTS │
│ (Output Interfaces) │
└─────────────────────────┬─────────────────────────┘
│
┌──────────────▼──────────────┐
│ DRIVEN ADAPTERS │
│ (Repositories, External │
│ APIs, Message Publishers) │
└──────────────┬──────────────┘
│
┌──────────────▼──────────────┐
│ SECONDARY ACTORS │
│ (Database, External APIs, │
│ Message Queues) │
└─────────────────────────────┘
Core Rule: Application Core defines Ports. Adapters implement or use them.
| Concept | Description | Location |
|---|---|---|
| Port | Interface defining how to interact with the core | Application/Domain |
| Driving Port | Input interface (how to use the application) | Application layer |
| Driven Port | Output interface (what the application needs) | Application/Domain |
| Driving Adapter | Implements input mechanism (HTTP, CLI) | Infrastructure |
| Driven Adapter | Implements external dependencies | Infrastructure |
| Application Core | Business logic, isolated from I/O | Domain + Application |
| Violation | Where to Look | Severity |
|---|---|---|
| Core depends on adapter | Domain importing Infrastructure | Critical |
| Missing port abstraction | Direct external service call | Critical |
| Business logic in adapter | if/switch in adapter | Critical |
| Framework in core | Symfony/Laravel in Domain | Warning |
| Port with implementation details | Interface using DB types | Warning |
| Adapter without port | Controller calling repository directly | Warning |
<?php
declare(strict_types=1);
namespace Application\Order\Port\Input;
use Application\Order\DTO\CreateOrderRequest;
use Application\Order\DTO\CreateOrderResponse;
interface CreateOrderUseCaseInterface
{
public function execute(CreateOrderRequest $request): CreateOrderResponse;
}
<?php
declare(strict_types=1);
namespace Domain\Order\Port\Output;
use Domain\Order\Entity\Order;
use Domain\Order\ValueObject\OrderId;
interface OrderRepositoryInterface
{
public function findById(OrderId $id): ?Order;
public function save(Order $order): void;
public function nextIdentity(): OrderId;
}
<?php
declare(strict_types=1);
namespace Infrastructure\Http\Controller;
use Application\Order\Port\Input\CreateOrderUseCaseInterface;
use Application\Order\DTO\CreateOrderRequest;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
final readonly class CreateOrderController
{
public function __construct(
private CreateOrderUseCaseInterface $createOrder
) {}
public function __invoke(Request $request): JsonResponse
{
$dto = CreateOrderRequest::fromArray($request->toArray());
$response = $this->createOrder->execute($dto);
return new JsonResponse($response->toArray(), 201);
}
}
<?php
declare(strict_types=1);
namespace Infrastructure\Persistence\Doctrine;
use Domain\Order\Entity\Order;
use Domain\Order\Port\Output\OrderRepositoryInterface;
use Domain\Order\ValueObject\OrderId;
use Doctrine\ORM\EntityManagerInterface;
final readonly class DoctrineOrderRepository implements OrderRepositoryInterface
{
public function __construct(
private EntityManagerInterface $em
) {}
public function findById(OrderId $id): ?Order
{
return $this->em->find(Order::class, $id->value);
}
public function save(Order $order): void
{
$this->em->persist($order);
$this->em->flush();
}
public function nextIdentity(): OrderId
{
return OrderId::generate();
}
}
For detailed information, load these reference files:
references/ports-patterns.md — Driving and Driven Port patternsreferences/adapters-patterns.md — Adapter implementation patternsreferences/testing-patterns.md — Testing strategies for hexagonal architecturereferences/antipatterns.md — Common violations with detection patterns还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.
中文简介正在准备中。当前显示原文说明。
在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。
中文简介正在准备中。当前显示原文说明。
Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.
中文简介正在准备中。当前显示原文说明。
Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.
中文简介正在准备中。当前显示原文说明。
Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.
中文简介正在准备中。当前显示原文说明。
[00] META. Orchestrate skills into dynamic chains for complex tasks. Analyzes the task, discovers available skills, builds an optimal chain, explains why each skill is needed, and executes step-by-step with user confirmation. Use for any complex task requiring multiple thinking/research/analysis steps. Triggers on "plan this", "how to approach", "what's the strategy", "build a plan", or any multi-step problem requiring skill orchestration.
中文简介正在准备中。当前显示原文说明。