The Five Responses
| Class | Status | Payload | Typical controller |
|---|---|---|---|
ResourceCreatedResponse | 201 | {"data": {...}} | AbstractCreateResourceController |
ResourceViewResponse | 200 | {"data": {...}} | AbstractViewResourceController |
ResourceUpdatedResponse | 200 | {"data": {...}} | AbstractUpdateResourceController |
ResourceDeletedResponse | 200 | {"data": {...}} | AbstractDeleteResourceController |
ResourceListResponse | 200 | {"data": [...], "pagination": {...}} | AbstractListResourceController |
ResourceListResponse additionally requires a PaginationResponseInterface.
Usage
Create / View / Update / Delete
$animal->toArray($mode) with the matching mode constant, so per-mode field exclusions from $resource->excludeFromMode($mode) are applied automatically.
List
OffsetPaginationPaginationResponse / CursorPaginationPaginationResponse. The JsonRenderer adds the pagination key to the output automatically.
Output shape:
OpenAPI Schema
You do not calladdProperty(...) or setDescription(...) on these response classes. Their getDocumentation() returns an empty ApivalkResponseDocumentation as a placeholder; the actual schema for OpenAPI is built by ResponseDocumentationFactory::create($resource, $mode) during spec generation, using the resource’s properties and per-mode exclusions as the source of truth.
This means a documentation change on the resource (adding a field, excluding one from list, etc.) updates every relevant CRUD response schema at once.
Writing a Custom Response
If you need a response shape that doesn’t fit these five envelopes (e.g. a bulk-import result), just return any subclass ofAbstractApivalkResponse as normal — see the Response page. You’re not forced into the resource responses.