symfony-knowledge

Symfony 框架知识库:涵盖 Symfony PHP 项目的架构要点,包括与领域驱动设计(DDD)的集成、持久化、依赖注入(DI)、安全、消息传递(messenger)、工作流(workflow)、事件、基础设施组件、测试以及常见反模式等内容。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "symfony-knowledge":https://skillpi.com/zh/skills/deepskill-439ae5cf87e4fd48fb13c607958fce3c50369c5438b3ad04016804169b76bc2e。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

Symfony 框架知识库:涵盖 Symfony PHP 项目的架构要点,包括与领域驱动设计(DDD)的集成、持久化、依赖注入(DI)、安全、消息传递(messenger)、工作流(workflow)、事件、基础设施组件、测试以及常见反模式等内容。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: symfony-knowledge
description: Symfony framework knowledge base. Provides architecture, DDD integration, persistence, DI, security, messenger, workflow, events, infrastructure components, testing, and antipatterns for Symfony PHP projects.

Symfony Knowledge Base

Quick reference for Symfony framework patterns, DDD integration, and PHP implementation guidelines for auditing and generating Symfony-based applications.

Core Principles

  • Bundle System — Symfony's plugin mechanism. Third-party code is installed as bundles; application code lives outside bundles in src/.
  • Symfony Flex — Automates bundle installation via recipes. Standard dirs: config/, src/, public/, var/, migrations/, tests/, templates/.
  • Kernel — Entry point that boots the container, registers bundles, loads configuration. Must remain thin — no business logic.

Quick Checklists

DDD-Compatible Symfony Project

  • [ ] Domain layer has zero Symfony imports
  • [ ] Doctrine mapping uses XML or PHP config (not entity attributes)
  • [ ] Controllers are invokable (single action per class)
  • [ ] Messenger handles commands and queries via separate buses
  • [ ] Value Objects use custom Doctrine types
  • [ ] Repository interfaces in Domain, implementations in Infrastructure
  • [ ] services.yaml binds interfaces to implementations
  • [ ] Domain events are dispatched, not Doctrine lifecycle events
  • [ ] Authorization uses Voters delegating to domain Specifications
  • [ ] Workflow guards delegate to domain Specifications (no inline business logic)
  • [ ] Domain defines its own EventDispatcherInterface (not Symfony's)
  • [ ] Infrastructure components (Cache, HTTP Client) accessed via domain ports

Clean Architecture in Symfony

  • [ ] No use Symfony\ in Domain or Application layers
  • [ ] No use Doctrine\ in Domain layer
  • [ ] Use Cases accept Command/Query DTOs, not Request objects
  • [ ] Controllers only map HTTP to Use Case calls
  • [ ] EventSubscribers do not contain business logic
  • [ ] Compiler passes do not encode domain rules

Common Violations Quick Reference

Violation Where to Look Severity
Doctrine attributes in Domain entities Domain/**/*.php with #[ORM\ Critical
Symfony Request/Response in Application layer Application/**/*.php Critical
Business logic in Controller Controllers with if/switch on domain state Warning
Fat Controller (multiple actions) Controllers with 2+ public methods Warning
Entity used as DTO across layers Entity passed to templates/serializers directly Warning
Service Locator via ContainerInterface $container->get() in services Critical
Doctrine EventListener with domain logic EventListener classes with business rules Warning
Hard-coded service IDs $container->get('service.id') Warning
UserInterface in Domain Domain/**/*.php with implements UserInterface Critical
Missing Messenger retry strategy messenger.yaml without retry_strategy Warning
Business logic in Workflow listener Guard/transition listeners with domain rules Warning
Symfony EventDispatcher in Domain Domain/**/*.php with use Symfony\Contracts\EventDispatcher Critical
Direct infrastructure in Application Application/**/*.php with CacheInterface, LockFactory Warning

PHP 8.4 Symfony Patterns

Invokable Controller (Single Action)

<?php
declare(strict_types=1);
namespace App\Order\Presentation\Api;

use App\Order\Application\Command\CreateOrderCommand;
use App\Order\Application\UseCase\CreateOrderUseCase;
use Symfony\Component\HttpFoundation\{JsonResponse, Request, Response};
use Symfony\Component\Routing\Attribute\Route;

#[Route('/api/orders', methods: ['POST'])]
final readonly class CreateOrderAction
{
    public function __construct(private CreateOrderUseCase $createOrder) {}

    public function __invoke(Request $request): JsonResponse
    {
        $data = $request->toArray();
        $orderId = $this->createOrder->execute(new CreateOrderCommand(
            customerId: $data['customer_id'],
            items: $data['items'],
        ));

        return new JsonResponse(['id' => $orderId->value], Response::HTTP_CREATED);
    }
}

Use Case (Application Service)

<?php
declare(strict_types=1);
namespace App\Order\Application\UseCase;

use App\Order\Domain\Entity\Order;
use App\Order\Domain\Repository\OrderRepositoryInterface;
use App\Shared\Domain\EventDispatcherInterface;

final readonly class CreateOrderUseCase
{
    public function __construct(
        private OrderRepositoryInterface $orders,
        private EventDispatcherInterface $events,
    ) {}

    public function execute(CreateOrderCommand $command): OrderId
    {
        $order = Order::create($command->customerId, $command->items);
        $this->orders->save($order);

        foreach ($order->releaseEvents() as $event) {
            $this->events->dispatch($event);
        }

        return $order->id();
    }
}

Messenger Command Handler

<?php
declare(strict_types=1);
namespace App\Order\Application\Handler;

use App\Order\Application\Command\ConfirmOrderCommand;
use App\Order\Domain\Repository\OrderRepositoryInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler(bus: 'command.bus')]
final readonly class ConfirmOrderHandler
{
    public function __construct(private OrderRepositoryInterface $orders) {}

    public function __invoke(ConfirmOrderCommand $command): void
    {
        $order = $this->orders->findById($command->orderId);
        $order->confirm();
        $this->orders->save($order);
    }
}

References

For detailed information, load these reference files:

  • references/architecture.md — Bundle system, Flex recipes, standard vs DDD-aligned directory layout
  • references/ddd-integration.md — Domain purity, Messenger CQRS, Domain Events, Value Objects with Doctrine
  • references/routing-http.md — Invokable controllers, EventSubscribers, attribute routing, validation
  • references/persistence.md — Doctrine ORM mapping, repositories, migrations, keeping Doctrine out of Domain
  • references/dependency-injection.md — services.yaml, auto-wiring, tagged services, compiler passes, interface binding
  • references/testing.md — WebTestCase, KernelTestCase, functional tests, fixtures, Messenger handler testing
  • references/security.md — UserInterface adapter, Voters with Specifications, firewalls, password hashing, auth events
  • references/messenger-advanced.md — Multiple buses, transports, retry strategy, DLQ, middleware, workers, serialization
  • references/workflow.md — StateMachine for aggregates, enum places, guards with Specifications, audit trail
  • references/event-system.md — EventDispatcher patterns, kernel events, domain event dispatching, PSR-14
  • references/infrastructure-components.md — Cache, Lock, RateLimiter, HTTP Client, Serializer, Scheduler with DDD ports
  • references/antipatterns.md — Fat controllers, entity as DTO, Doctrine in Domain, Service Locator, detection patterns

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 提供 Symfony 框架的全面知识库,涵盖架构、DDD 集成、持久化、依赖注入、安全、消息传递、工作流、事件、基础设施组件、测试及反模式等内容。
  • 面向 PHP 开发者,特别是使用 Symfony 框架进行企业级应用开发的用户,具有明确的实用价值和广泛受众。
  • 内容详实,结构清晰,提供了快速检查清单、常见违规参考、PHP 8.4 模式示例等,能有效提升开发效率和代码质量。
触发精准95/100

亮点

  • description 明确描述了 Skill 的功能和覆盖范围,触发词精准完整,边界清晰,覆盖 Symfony 框架的多个核心方面。
结构规范90/100

亮点

  • Skill 结构清晰,包含核心原则、快速检查清单、常见违规参考、PHP 8.4 模式示例和参考文件列表。
  • 有明确的章节划分和出口条件(参考文件),frontmatter 完整,单文件未超过 500 行。
执行可靠85/100

亮点

  • Skill 作为知识库,主要提供参考信息和模式示例,不涉及具体的工具调用或不可逆操作。
  • 内容来源明确,参数正确,覆盖了主要的使用场景和常见违规情况。
证据可验 (前四项均值)89/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。