api-platform-dto-resources — Claude Code skill
The api-platform-dto-resources skill decouples your API contract from Doctrine entities in API Platform via Symfony's Object Mapper.
MIT ★ 234 updated 2026-10-05
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a claude-codeWhat api-platform-dto-resources does
The skill streamlines DTO resources in API Platform v5, v4.4, and v4.3 with built-in Object Mapper support. Instead of returning the entity directly, define an #[ApiResource] class as a DTO and bind it to the entity using #[Map(source: ...)] and #[Map(target: ...)]. Transformed fields (renamed, formatted, computed) use #[Map(transform: ...)].
It covers three approaches: automatic Object Mapper via stateOptions, separate input and output classes per operation, and custom ProcessorInterface for intricate logic. Object Mapper requires Symfony 7.3+ and does not work on API Platform 3.4 (manual mapping in provider and processor is needed there). On API Platform 5.0, ObjectMapperProcessor moves to ObjectMapperInputProcessor and ObjectMapperOutputProcessor.
The skill steers around the removal of DataTransformerInterface and clarifies the shift in processor architecture. Output includes resource classes with mappings, the chosen mapping path and rationale, and tests for each operation's request and response.
What it helps with
- Decouple API contract from Doctrine entity
- Rename entity fields in the API layer without code duplication
- Define separate request and response shapes per operation
- Migrate from removed DataTransformerInterface to Object Mapper
- Compute and output derived fields not stored in the entity
Example prompts for the agent
- Create a DTO for your entity with field mapping via #[Map]
- Set up input and output classes for create and update operations
- Write a custom processor to handle complex data transformations
How to install api-platform-dto-resources
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a claude-code2Manually: put the files in place
~/.claude/skills/api-platform-dto-resources/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/api-platform-dto-resources/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a codex2Manually: put the files in place
.agents/skills/api-platform-dto-resources/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a cursor2Manually: put the files in place
.cursor/skills/api-platform-dto-resources/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install dev-toolings/superpowers-symfony content/skills/api-platform-dto-resources2Manually: put the files in place
.github/skills/api-platform-dto-resources/SKILL.md1Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a gemini-cli2Platform CLI
gemini skills install https://github.com/dev-toolings/superpowers-symfony --path content/skills/api-platform-dto-resourcesManually: put the files in place
.devin/skills/api-platform-dto-resources/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about api-platform-dto-resources
How do I install api-platform-dto-resources in Claude Code?
Run npx skills add dev-toolings/superpowers-symfony --skill api-platform-dto-resources -a claude-code, then open ~/.claude/skills/api-platform-dto-resources/SKILL.md.
What does this skill do?
It automates entity-to-DTO mapping in API Platform using Symfony's Object Mapper, enabling you to keep your API contract separate from the Doctrine entity and define different shapes for request and response data.
Which versions of API Platform does it support?
Object Mapper works on API Platform v5, v4.4, and v4.3, but requires Symfony 7.3+. On API Platform 3.4 and Symfony 6.4 LTS, manual mapping in provider and processor is required.
Source text
SKILL.md · MIT
--- name: api-platform-dto-resources description: 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 capabilities: [read, search, edit, shell] tags: [api-platform] # projected by `bun run build` — do not edit by hand allowed-tools: - Read - Glob - Grep - Write - Edit - Bash --- # 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 1. Require `symfony/object-mapper` and set `stateOptions: new Options(entityClass: ...)` on the DTO resource. 2. Bind the DTO and the entity with `#[Map(source: ...)]` and `#[Map(target: ...)]`, and use `#[Map(transform: ...)]` for computed fields. 3. For distinct shapes, create input and output classes and wire them with `input:` and `output:` on each operation. 4. When mapping needs real logic, write a custom `ProcessorInterface` that calls `ObjectMapperInterface::map()`. 5. Test each operation: payload in, response shape out. ## Guardrails - The automatic Object Mapper provider and processor only apply when `stateOptions` has an `entityClass` and both the DTO and the entity carry `#[Map]`. - `DataTransformerInterface` is 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 `ProviderInterface` and a `ProcessorInterface`. - `ObjectMapperProcessor` is removed in 5.0: the automatic path uses `ObjectMapperInputProcessor` and `ObjectMapperOutputProcessor` (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`
© dev-toolings · MIT · dev-toolings/superpowers-symfony