Add jsonapi.org compliant APIs to your Laravel 5 application. Based on the framework agnostic packages neomerx/json-api and cloudcreativity/json-api.
From jsonapi.org
If you've ever argued with your team about the way your JSON responses should be formatted, JSON API is your anti-bikeshedding weapon.
By following shared conventions, you can increase productivity, take advantage of generalized tooling, and focus on what matters: your application. Clients built around JSON API are able to take advantage of its features around efficiently caching responses, sometimes eliminating network requests entirely.
For full information on the spec, plus examples, see http://jsonapi.org
- Encoding of JSON API responses using the
neomerx/json-api
package. - Start JSON API support on route groups through a single piece of middleware, which automatically checks request headers and loads JSON API query parameters.
- Registration of JSON API defined resource end-points via a simple route helper.
- Define supported JSON API extensions via middleware (on route groups or individual controllers).
- A JSON API controller providers helpers to:
- Automatically check request query parameters.
- Decode request body content into objects with a standard, fluent, interface. Makes handling content easier.
- Validate request body content as it is being decoded, including using Laravel validators on resource object attributes.
- Helpers for sending common JSON API responses, that automatically include requested encoding parameters, the encoded media type plus registered supported extensions.
- Rendering of exceptions into JSON API error responses, plus easy sending of error responses via throwable JSON API error objects.
- Configuration settings - including schemas, encoders, decoders and exception rendering - all defined in a configuration file in your Laravel application.
This repository is under development but is considered relatively stable. Tagged versions exist and we have live applications that are using the repository.
Apache License (Version 2.0). Please see License File for more information.
Install using Composer:
$ composer require cloudcreativity/laravel-json-api
Add the package service provider to your config/app.php
providers array. It is important that it is added before your application's route service provider.
\CloudCreativity\JsonApi\ServiceProvider::class