Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

api-platform-crud

БесплатноБез исполняемых скриптовНе проверен

Create complete REST API CRUD operations using API Platform 4 with DDD and CQRS patterns. Use when adding new API resources, implementing CRUD endpoints…

diegosouzapwот diegosouzapw★ 68 звёзд на GitHub

Об этом скилле

API Platform CRUD Skill

Context (Input)

  • Need to create new API resource with REST endpoints
  • Implementing CRUD operations (Create, Read, Update, Delete)
  • Adding DTOs for input/output transformation
  • Configuring API Platform operations, filters, or pagination
  • Working with state processors following CQRS pattern

Task (Function)

Implement production-ready REST API CRUD operations following DDD, CQRS, and hexagonal architecture patterns.

Success Criteria:

  • All CRUD operations functional (POST, GET, PUT, PATCH, DELETE)
  • DTOs properly validated
  • Domain entities remain framework-agnostic
  • Command bus pattern used for write operations
  • make ci outputs "✅ CI checks successfully passed!"

Template examples reference MongoDB/Doctrine ODM. In this service, use Doctrine ORM with MySQL (.orm.xml mappings, EntityManagerInterface) while keeping the same layering and DTO/processor patterns.


Quick Start: Complete CRUD in 10 Steps

Full Implementation Example: See examples/complete-customer-crud.md for detailed code.

Step 1: Create Domain Entity

Create pure PHP entity in src/Core/{Context}/Domain/Entity/{Entity}.php

  • ❌ NO Doctrine annotations/attributes
  • ❌ NO Symfony imports
  • ❌ NO API Platform attributes
  • ✅ Pure business logic only

Step 2: Create Doctrine XML Mapping

Create config/doctrine/{Entity}.mongodb.xml with field mappings and indexes.

See: database-migrations skill for XML mapping patterns.

Step 3: Create Input DTOs

Create three DTOs in src/Core/{Context}/Application/DTO/:

  • {Entity}Create - For POST requests
  • {Entity}Put - For PUT requests (full update)
  • {Entity}Patch - For PATCH requests (partial update)

See: reference/dto-validation-patterns.md

Step 4: Configure Validation

Create config/validator/{Entity}.yaml with validation rules for each DTO.

Step 5: Create API Platform Resource Configuration

Create config/api_platform/resources/{entity}.yaml:

App\Core\{Context}\Domain\Entity\{Entity}:
  shortName: { Entity }
  operations:
    ApiPlatform\Metadata\GetCollection: ~
    ApiPlatform\Metadata\Get: ~
    ApiPlatform\Metadata\Post:
      input: App\Core\{Context}\Application\DTO\{Entity}Create
      processor: App\Core\{Context}\Application\Processor\Create{Entity}Processor
    ApiPlatform\Metadata\Put:
      input: App\Core\{Context}\Application\DTO\{Entity}Put
      processor: App\Core\{Context}\Application\Processor\Update{Entity}Processor
    ApiPlatform\Metadata\Patch:
      input: App\Core\{Context}\Application\DTO\{Entity}Patch
      processor: App\Core\{Context}\Application\Processor\Patch{Entity}Processor
    ApiPlatform\Metadata\Delete: ~

See: reference/configuration-patterns.md for detailed patterns.

Step 6: Configure Serialization Groups

Create config/serialization/{Entity}.yaml to control which fields are exposed.

Step 7: Create State Processors

Create processors in src/Core/{Context}/Application/Processor/:

  • Create{Entity}Processor - Handles POST
  • Update{Entity}Processor - Handles PUT
  • Patch{Entity}Processor - Handles PATCH

Each processor:

  1. Receives DTO
  2. Transforms to Command
  3. Dispatches via Command Bus
  4. Returns resulting Entity

Step 8: Create Command and Handler

Create:

  • Command in Application/Command/{Action}{Entity}Command.php
  • Handler in Application/CommandHandler/{Action}{Entity}CommandHandler.php

Handler contains business logic and calls repository.

See: implementing-ddd-architecture for CQRS patterns.

Step 9: Create Repository

Create:

  • Interface in Domain/Repository/{Entity}RepositoryInterface.php
  • Implementation in Infrastructure/Repository/{Entity}Repository.php
  • Register in config/services.yaml

See: database-migrations skill for repository patterns.

Step 10: Configure Filters (Optional)

Add filters in config/services.yaml for search, ordering, etc.

See: reference/filters-and-pagination.md


Architecture Flow

REST Request → API Platform
            ↓
        Processor (Application)
            ↓
        DTO → Transformer → Command
            ↓
        Command Bus
            ↓
        Handler (Application)
            ↓
        Entity (Domain) ← Repository (Infrastructure)
            ↓
        MongoDB

See: reference/configuration-patterns.md for detailed architecture.


Constraints (Parameters)

NEVER

  • Add framework annotations/attributes to Domain entities
  • Put business logic in Processors (use Handlers)
  • Skip validation configuration
  • Use PHP attributes for API Platform config (use YAML)
  • Violate layer boundaries (check with `make
Полный SKILL.md на GitHub

Установить api-platform-crud в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

metadata.json

FAQ

Что делает скилл api-platform-crud?

Create complete REST API CRUD operations using API Platform 4 with DDD and CQRS patterns. Use when adding new API resources, implementing CRUD endpoints, creating DTOs, configuring operations, or setting up state processors. Follows the repository's hexagonal architecture with YAML resource configuration and command bus pattern.

Как установить скилл api-platform-crud?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл api-platform-crud запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить api-platform-crud с