mcpField
A
api-platform-state-providers

api-platform-state-providers

github.com/dev-toolingsDevelopment22779 installsUpdated 3w ago
Repository

About api-platform-state-providers

A Symfony skill for implementing API Platform state providers and processors. It covers alternate data sources, Doctrine delegation, persistence hooks, and operation-specific wiring.

Key features

  1. 01Custom state providers
  2. 02Custom state processors
  3. 03Doctrine provider and processor delegation
  4. 04Provider and processor operation wiring
  5. 05Persistence and side-effect ordering

Use cases

  1. 01Read data from a non-Doctrine source
  2. 02Apply tenant scoping to Doctrine results
  3. 03Run business logic around persistence
  4. 04Dispatch a query or command from a v4 read endpoint

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/dev-toolings/superpowers-symfony --skill api-platform-state-providers

After installing, type/api-platform-state-providersin Claude Code to confirm it loaded.

Bundled filesreference.md

Details

From the project README

Api Platform State Providers (Symfony)

Use when

  • Reading data from a source other than the default Doctrine provider.
  • Wrapping the Doctrine provider to post-process results (return a DTO, enforce a tenant scope).
  • Business logic must run before or after persisting (hashing, slug, dispatching a message).
  • A v4 read endpoint must dispatch a query or command through a processor.

Default workflow

  1. Implement ProviderInterface::provide() returning iterable|object|null, where null gives a 404 (v3.4 declares mixed).
  2. To keep Doctrine fetching, inject api_platform.doctrine.orm.state.item_provider and api_platform.doctrine.orm.state.collection_provider with #[Autowire].
  3. Implement ProcessorInterface::process() and delegate to api_platform.doctrine.orm.state.persist_processor or remove_processor.
  4. Wire them with provider: and processor: on the resource or the operation; autoconfiguration registers them, and the api_platform.state_provider or api_platform.state_processor tag is only needed without it.
  5. For a processor on GET or GetCollection, add write: true (v4 only).

Guardrails

  • Run pre-persist logic before calling the inner processor and side effects after it returns.
  • A processor returns the created or modified object, and nothing for DELETE.
  • write: true on safe methods is v4 only: v3.4 processors run on write methods only.
  • DataProvider and DataPersister are v2 interfaces and no longer exist.

Progressive disclosure

  • Use this file for execution posture and risk controls.
  • Open references when deep implementation details are needed.

Output contract

  • The providers and processors added, and the operations they are wired to.
  • Which built-in services are decorated.
  • Tests for the not-found, success, and side-effect paths.

References

  • reference.md

Comments

Markdown supported