Download the PHP package happyr/json-api-response-factory without Composer
On this page you can find all versions of the php package happyr/json-api-response-factory. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download happyr/json-api-response-factory
More information about happyr/json-api-response-factory
Files in happyr/json-api-response-factory
Package json-api-response-factory
Short Description Response factory in compliance with apijson
License MIT
Informations about the package json-api-response-factory
JsonApi Response factory
A small wrapper around league/fractal
to support JsonApi error AND success responses.
Install
Usage
ResponseFactory
can be used for creating single object, collection of objects or custom responses.
Transformers
Each object that is used in the response needs a transformer that implements Happyr\JsonApiResponseFactory\Transformer\AbstractTransformer
:
Response with single item
Response will look like this:
Response with collection of items
Response will look like this:
Custom responses
To use response ResponseFactory
to create response with custom payload/status codes you should create class that implements Happyr\JsonApiResponseFactory\ResponseModelInterface
:
and pass it to response factory:
Response will look lie this:
In src/Model/
there are models for usual message responses (accepted, created etc), and error responses in compliance with json-api error standard
that you can use, or take a hint how we are using the library and write your own models.
Example response for message:
Example response for validation failed:
All versions of json-api-response-factory with dependencies
ext-json Version *
league/fractal Version ^0.18 || ^0.19 || ^0.20
symfony/http-foundation Version ^5.4 || ^6.0
symfony/validator Version ^5.4 || ^6.0