api-platform-state-providers

Installation
SKILL.md

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).
Installs
64
GitHub Stars
224
First Seen
Sep 18, 2026