dev-toolings/superpowers-symfony116 installs
api-platform-dto-resources
Map entities to API DTOs in API Platform (v5, 4.4, 4.3) with the Symfony Object Mapper (#[Map], stateOptions) for decoupled input/output contracts
How do I install this agent skill?
npx skills add https://github.com/dev-toolings/superpowers-symfony --skill api-platform-dto-resourcesIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides technical guidance for implementing DTO mapping in Symfony API Platform applications. It is generally safe but carries a low risk of indirect prompt injection due to its interaction with user-provided source code.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
Api Platform Dto Resources (Symfony)
Use when
- The
#[ApiResource]class must be the API contract, decoupled from the Doctrine entity. - Entity and API fields differ in name or format (rename, formatted price, computed value).
- Create, update, or list operations need their own input or output shape.
- Migrating code that relied on
DataTransformerInterface, which no longer exists.
Default workflow
- Require
symfony/object-mapperand setstateOptions: new Options(entityClass: ...)on the DTO resource. - Bind the DTO and the entity with
#[Map(source: ...)]and#[Map(target: ...)], and use#[Map(transform: ...)]for computed fields. - For distinct shapes, create input and output classes and wire them with
input:andoutput:on each operation. - When mapping needs real logic, write a custom
ProcessorInterfacethat callsObjectMapperInterface::map(). - Test each operation: payload in, response shape out.
Guardrails
- The automatic Object Mapper provider and processor only apply when
stateOptionshas anentityClassand both the DTO and the entity carry#[Map]. DataTransformerInterfaceis gone: use Object Mapper or a provider and processor.- No Object Mapper on 3.4 or on Symfony 6.4 LTS (it needs Symfony 7.3+): map manually in a
ProviderInterfaceand aProcessorInterface. ObjectMapperProcessoris removed in 5.0: the automatic path usesObjectMapperInputProcessorandObjectMapperOutputProcessor(4.3+).- Never return the entity itself from a DTO resource: only mapped fields reach the client.
Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.
Output contract
- The resource, input, and output classes with their
#[Map]bindings. - The mapping path chosen (Object Mapper or custom processor) and why.
- Tests showing the request and response shape of each operation.
References
reference.md
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/dev-toolings/superpowers-symfony/api-platform-dto-resources">View api-platform-dto-resources on skillZs</a>