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
- 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).