api-platform-serialization
Installation
SKILL.md
Api Platform Serialization (Symfony)
Use when
- Operations must expose different fields (list, read, create, update).
- A related resource must render as an IRI or be embedded.
- A response needs computed or role-dependent fields.
- A property needs normalizer options such as a date format.
Default workflow
- Name groups
entity:operationand setnormalizationContextanddenormalizationContextper operation. - Tag properties with
#[Groups]from the SerializerAttributenamespace, not the oldAnnotationone. - Control relations with
#[ApiProperty(readableLink: false, writableLink: false)]to force IRIs. - Apply per-property options with
#[Context]instead of writing a normalizer. - Add computed fields in a custom normalizer, and dynamic groups in a decorator of
api_platform.serializer.context_builder. - Prevent cycles with
#[MaxDepth]andenable_max_depth, and hide secrets with#[Ignore].