A
api-platform-state-providers
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
- 01Custom state providers
- 02Custom state processors
- 03Doctrine provider and processor delegation
- 04Provider and processor operation wiring
- 05Persistence and side-effect ordering
Use cases
- 01Read data from a non-Doctrine source
- 02Apply tenant scoping to Doctrine results
- 03Run business logic around persistence
- 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-providersAfter installing, type/api-platform-state-providersin Claude Code to confirm it loaded.
Bundled filesreference.md
Details
From the project READMEApi 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
- Implement
ProviderInterface::provide()returningiterable|object|null, wherenullgives a 404 (v3.4 declaresmixed). - To keep Doctrine fetching, inject
api_platform.doctrine.orm.state.item_providerandapi_platform.doctrine.orm.state.collection_providerwith#[Autowire]. - Implement
ProcessorInterface::process()and delegate toapi_platform.doctrine.orm.state.persist_processororremove_processor. - Wire them with
provider:andprocessor:on the resource or the operation; autoconfiguration registers them, and theapi_platform.state_providerorapi_platform.state_processortag is only needed without it. - For a processor on
GETorGetCollection, addwrite: 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: trueon safe methods is v4 only: v3.4 processors run on write methods only.DataProviderandDataPersisterare 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