Customization: DTOs, Serialization Groups & Custom Operations
Serialization Groups — Context-Specific Fields
#[Groups(['product:read'])]
public string $name;
#[Groups(['product:admin'])]
public string $internalCostPrice;
// exposed only in the admin-scoped operation, hidden from a general readControls which entity fields appear in a given API response per operation — avoiding accidentally leaking a sensitive field just because it exists on the entity.
DTOs When the API Shape Differs from the Entity
When the public API shape needs to diverge from the database entity (combined/renamed/omitted fields), a custom DTO decouples the two — the same Clean-Architecture principle of not letting internal schema details leak into a public contract, applied within API Platform's convenience-first defaults.
Custom Operations & Subresources
#[Post(uriTemplate: '/products/{id}/publish', controller: PublishProductController::class)]
// custom action beyond standard CRUD — for logic that doesn't fit create/read/update/delete
// GET /authors/{id}/books — subresource reflecting the entity relationship in the URLCustom operations accommodate business logic beyond generic CRUD ("publish this product"). Subresources auto-generate nested-relationship endpoints from entity associations, following standard REST URL conventions.
Security & Fit
Authentication/authorization builds on Symfony's existing security component rather than reinventing it. API Platform pays off most for substantial, fairly standard CRUD-style APIs across many entities — decoupled backend for a separate frontend (React/Vue SPA) is a natural fit; highly unconventional APIs fighting the framework's conventions may find a more minimal, manually-controlled approach less friction-filled overall.
Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free