Token导航 LogoToken导航

Agent Skill · 研究检索

symfony(symfony 搜索)

symfony 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

symfony 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 63,891。

总安装 309周安装 13GitHub Stars 8下载 108核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:symfony(symfony 搜索)
来源仓库:https://github.com/ar4mirez/samuel
仓库路径:skills/symfony
安装命令:
npx skills add https://github.com/ar4mirez/samuel --skill symfony
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/ar4mirez/samuel --skill symfony

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

symfony 用于查找、检索和筛选相关信息。适合在 Codex、Claude、Cursor、Gemini CLI 中根据关键词或任务场景快速定位候选结果。通过 npx skills add 命令从指定 GitHub 仓库安装并使用。安装前需确认权限范围、维护状态,注意是否会触发联网、命令执行或文件读写。

建议结合原始 README 核验具体用法和功能边界。

来源仓库内路径:skills/symfony

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/ar4mirez/samuel --skill symfony;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

symfony 怎么安装?

在终端执行 npx skills add https://github.com/ar4mirez/samuel --skill symfony。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

symfony 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

symfony 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

symfony 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

symfony 用的人多吗?

公开数据是累计安装 309 次,近一周安装 13 次,下载 108 次,GitHub 8 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

symfony 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
symfony

symfony 搜索 · 本页

3098需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Symfony Framework Guide

Applies to: Symfony 7+, PHP 8.2+, Doctrine ORM, Twig, Messenger

Core Principles

  1. Convention Over Configuration: Follow Symfony defaults unless there is a strong reason not to
  2. Dependency Injection: Constructor injection for all services; avoid service locators
  3. Thin Controllers: Controllers delegate to services; no business logic in controllers
  4. DTOs at Boundaries: Never expose Doctrine entities directly to API consumers
  5. Events for Decoupling: Use EventDispatcher and Messenger for side effects
  6. Explicit Configuration: Use PHP 8 attributes for routing, ORM mapping, and validation

Guardrails

Version and Dependencies

  • Target Symfony 7.x with PHP 8.2+
  • Use Composer with composer.lock committed
  • Use Symfony Flex for bundle management
  • Pin major versions in composer.json; run composer audit before adding dependencies

Code Style

  • All files start with declare(strict_types=1);
  • Use PSR-12 coding standard; run php-cs-fixer fix before committing
  • Run PHPStan at level 8+ (vendor/bin/phpstan analyse src)
  • Use PHP 8 attributes (not annotations) for routing, ORM, validation
  • Follow Symfony naming: PascalCase classes, camelCase methods, snake_case config keys

Controller Rules

  • Extend AbstractController only when you need its shortcuts
  • One action per method; keep under 20 lines
  • Use #[Route] attribute on both class and method
  • Use #[MapRequestPayload] for automatic DTO deserialization and validation
  • Return JsonResponse for APIs; never echo or die()
  • Use serialization groups to control response shape

Entity Rules

  • Use PHP 8 attributes for all Doctrine mapping (#[ORM\Entity], #[ORM\Column], etc.)
  • Always set repositoryClass on entities
  • Use #[ORM\HasLifecycleCallbacks] sparingly; prefer Doctrine event listeners
  • Initialize collections in constructor: $this->items = new ArrayCollection()
  • Use DateTimeImmutable for all date columns
  • Add database indexes for frequently queried columns with #[ORM\Index]
  • Fluent setters return static for chaining

Service Rules

  • One responsibility per service class
  • All dependencies via constructor injection (use readonly promoted properties)
  • Never inject EntityManagerInterface into controllers; inject repositories or services
  • Use #[AsMessageHandler] for async operations
  • Tag services only when autowiring cannot resolve

Project Structure

myapp/
├── bin/
│   └── console                # Symfony CLI
├── config/
│   ├── packages/             # Per-package YAML config
│   │   ├── doctrine.yaml
│   │   ├── security.yaml
│   │   ├── messenger.yaml
│   │   └── ...
│   ├── routes/               # Route imports
│   ├── routes.yaml
│   ├── services.yaml         # Service definitions and autowiring
│   └── bundles.php           # Registered bundles
├── migrations/               # Doctrine migrations (never edit after deploy)
├── public/
│   └── index.php            # Single entry point
├── src/
│   ├── Controller/          # HTTP controllers (thin)
│   ├── Dto/                 # Request/response DTOs
│   ├── Entity/              # Doctrine entities
│   ├── Repository/          # Doctrine repositories
│   ├── Service/             # Business logic
│   ├── EventSubscriber/     # Event subscribers
│   ├── Message/             # Messenger messages
│   ├── MessageHandler/      # Messenger handlers
│   ├── Command/             # Console commands
│   ├── Form/                # Form types (web apps)
│   ├── Security/            # Voters, authenticators
│   └── Kernel.php
├── templates/               # Twig templates
├── tests/
│   ├── Controller/          # Functional tests
│   ├── Service/             # Unit tests
│   └── bootstrap.php
├── translations/            # i18n files
├── var/                     # Cache and logs (gitignored)
├── .env                     # Default env vars (committed)
├── .env.local               # Local overrides (gitignored)
├── composer.json
├── phpunit.xml.dist
└── symfony.lock
  • src/Dto/ keeps request/response data separate from entities
  • src/Message/ and src/MessageHandler/ follow Messenger conventions
  • var/ is ephemeral; never store persistent data there
  • config/packages/ files are loaded by environment (config/packages/test/)

Controllers and Routing

API Controller

#[Route('/api/v1/users')]
class UserController extends AbstractController
{
    public function __construct(
        private readonly UserService $userService,
    ) {}

    #[Route('', methods: ['GET'])]
    public function index(Request $request): JsonResponse
    {
        $page = $request->query->getInt('page', 1);
        $limit = $request->query->getInt('limit', 15);

        return $this->json(
            $this->userService->getPaginated($page, $limit),
            Response::HTTP_OK,
            [],
            ['groups' => 'user:read'],
        );
    }

    #[Route('', methods: ['POST'])]
    #[IsGranted('ROLE_ADMIN')]
    public function create(#[MapRequestPayload] CreateUserDto $dto): JsonResponse
    {
        return $this->json(
            $this->userService->create($dto),
            Response::HTTP_CREATED,
            [],
            ['groups' => 'user:read'],
        );
    }
}

Routing Tips

  • Prefer attribute routing over YAML for controller routes
  • Use YAML routes only for third-party bundle prefixes
  • Version API routes: /api/v1/...
  • Type-hint entities in action signatures for automatic ParamConverter

Doctrine ORM Basics

Entity with Validation

<?php

declare(strict_types=1);

namespace App\Entity;

use App\Repository\UserRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: 'users')]
#[ORM\HasLifecycleCallbacks]
class User
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 180, unique: true)]
    #[Assert\NotBlank]
    #[Assert\Email]
    private string $email;

    #[ORM\Column(type: Types::DATETIME_IMMUTABLE)]
    private \DateTimeImmutable $createdAt;

    public function __construct()
    {
        $this->createdAt = new \DateTimeImmutable();
    }

    // Getters and fluent setters (return static)
}

Repository

<?php

declare(strict_types=1);

namespace App\Repository;

use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/** @extends ServiceEntityRepository<User> */
class UserRepository extends ServiceEntityRepository
{
    public function __construct(ManagerRegistry $registry)
    {
        parent::__construct($registry, User::class);
    }

    public function findOneByEmail(string $email): ?User
    {
        return $this->createQueryBuilder('u')
            ->andWhere('u.email = :email')
            ->setParameter('email', strtolower($email))
            ->getQuery()
            ->getOneOrNullResult();
    }
}

Migration Workflow

php bin/console make:migration           # Generate from entity diff
php bin/console doctrine:migrations:migrate  # Apply migrations
php bin/console doctrine:schema:validate     # Check mapping vs DB
  • Always review generated migrations before running
  • Every migration must have a working down() method
  • Never edit migrations that have been applied to production

Twig Templates

Layout Pattern

{# templates/base.html.twig #}
<!DOCTYPE html>
<html>
<head>
    <title>{% block title %}App{% endblock %}</title>
    {% block stylesheets %}{% endblock %}
</head>
<body>
    {% block body %}{% endblock %}
    {% block javascripts %}{% endblock %}
</body>
</html>

{# templates/user/index.html.twig #}
{% extends 'base.html.twig' %}

{% block title %}Users{% endblock %}

{% block body %}
    <h1>Users</h1>
    {% for user in users %}
        <p>{{ user.name|e }}</p>
    {% else %}
        <p>No users found.</p>
    {% endfor %}
{% endblock %}
  • Always escape output (Twig auto-escapes by default; never use |raw on user data)
  • Use {% include %} for partials, {% embed %} for overridable partials
  • Keep logic minimal in templates; compute values in controller or service

Services and Dependency Injection

Service Definition

class UserService
{
    public function __construct(
        private readonly UserRepository $userRepository,
        private readonly EntityManagerInterface $entityManager,
        private readonly UserPasswordHasherInterface $passwordHasher,
        private readonly EventDispatcherInterface $eventDispatcher,
    ) {}

    public function create(CreateUserDto $dto): User
    {
        $user = new User();
        $user->setEmail($dto->email);
        $user->setPassword($this->passwordHasher->hashPassword($user, $dto->password));

        $this->entityManager->persist($user);
        $this->entityManager->flush();

        $this->eventDispatcher->dispatch(new UserCreatedEvent($user));

        return $user;
    }
}

services.yaml Essentials

services:
    _defaults:
        autowire: true
        autoconfigure: true

    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'
  • Rely on autowiring; only add explicit definitions when needed
  • Use #[Autowire] attribute for non-standard parameters
  • Use #[TaggedIterator] to inject all services with a specific tag

Form Handling

class UserType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options): void
    {
        $builder
            ->add('name', TextType::class)
            ->add('email', EmailType::class);
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults(['data_class' => User::class]);
    }
}
  • Always bind forms to a DTO or entity via data_class
  • Validate via constraints on the DTO/entity, not in the form type
  • Use CSRF protection (enabled by default for web forms)
  • For APIs, prefer #[MapRequestPayload] over Symfony forms

Security Basics

Voter Pattern

class PostVoter extends Voter
{
    public const EDIT = 'POST_EDIT';
    public const DELETE = 'POST_DELETE';

    protected function supports(string $attribute, mixed $subject): bool
    {
        return in_array($attribute, [self::EDIT, self::DELETE], true)
            && $subject instanceof Post;
    }

    protected function voteOnAttribute(
        string $attribute,
        mixed $subject,
        TokenInterface $token,
    ): bool {
        $user = $token->getUser();
        if (!$user instanceof User) {
            return false;
        }

        return $subject->getAuthor() === $user || $user->getRole() === 'admin';
    }
}

Security Configuration Checklist

  • Use password_hashers: auto (Symfony picks bcrypt/argon2 automatically)
  • Stateless firewalls for APIs (stateless: true)
  • JWT authentication via lexik/jwt-authentication-bundle for APIs
  • CSRF protection enabled for all web forms
  • Use #[IsGranted] attribute on controller actions
  • Use Voters for object-level authorization (not is_granted('ROLE_...') for fine-grained checks)
  • Never store plain-text passwords; always use UserPasswordHasherInterface

Console Commands

#[AsCommand(name: 'app:import-users', description: 'Import users from CSV')]
class ImportUsersCommand extends Command
{
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);
        // Implementation here
        $io->success('Import complete.');
        return Command::SUCCESS;
    }
}
  • Use #[AsCommand] attribute (not configure() for name/description)
  • Return Command::SUCCESS, Command::FAILURE, or Command::INVALID
  • Use SymfonyStyle for consistent output formatting
  • Inject services via constructor (commands are services)

Essential CLI Commands

# Development
symfony serve                              # Local dev server
php bin/console cache:clear                # Clear cache
php bin/console debug:router               # List all routes
php bin/console debug:container            # List all services

# Code Generation
php bin/console make:entity User
php bin/console make:controller UserController
php bin/console make:migration
php bin/console make:form UserType
php bin/console make:voter PostVoter
php bin/console make:command App:ImportUsers
php bin/console make:subscriber UserEventSubscriber
php bin/console make:message SendWelcomeEmail

# Database
php bin/console doctrine:database:create
php bin/console doctrine:migrations:migrate
php bin/console doctrine:schema:validate
php bin/console doctrine:fixtures:load

# Messenger
php bin/console messenger:consume async
php bin/console messenger:failed:show
php bin/console messenger:failed:retry

# Testing and Quality
php bin/phpunit
php bin/phpunit --coverage-html coverage
vendor/bin/phpstan analyse src
vendor/bin/php-cs-fixer fix

# Production
composer install --no-dev --optimize-autoloader
php bin/console cache:clear --env=prod
php bin/console cache:warmup --env=prod

Do and Don't

Do

  • Use constructor injection with readonly promoted properties
  • Use DTOs for all API request/response payloads
  • Use Messenger for async work (emails, notifications, heavy processing)
  • Use Voters for authorization logic
  • Use Events for decoupling side effects from core logic
  • Use serialization groups to control JSON output shape
  • Use DateTimeImmutable for all temporal data
  • Run php bin/console doctrine:schema:validate in CI

Don't

  • Don't put business logic in controllers (delegate to services)
  • Don't flush EntityManager inside loops (batch with $em->flush() once)
  • Don't use $_GET, $_POST, $_SERVER (use Request object)
  • Don't hardcode config values (use %env()% syntax or #[Autowire])
  • Don't bypass the security component (no manual session/cookie auth)
  • Don't create "god services" that handle everything (single responsibility)
  • Don't ignore Symfony deprecation warnings (they become errors on upgrade)

Advanced Topics

For detailed patterns and production guidance, see:

  • references/patterns.md -- Doctrine advanced patterns, event system, Messenger, API Platform, testing, deployment

External References

平台分布

Codex

34.08%
按下载量换算37

Claude

33.34%
按下载量换算36

Cursor

19.8%
按下载量换算21

Gemini CLI

10.18%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills