Download the PHP package ride/lib-http-jsonapi without Composer
On this page you can find all versions of the php package ride/lib-http-jsonapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ride/lib-http-jsonapi
More information about ride/lib-http-jsonapi
Files in ride/lib-http-jsonapi
Package lib-http-jsonapi
Short Description JSON API library of the Ride framework
License MIT
Informations about the package lib-http-jsonapi
Ride: JSON API Library
JSON API library of the PHP Ride framework.
Check http://jsonapi.org for a full reference of the standard.
What's In This Library?
JsonApi
The JsonApi class is the starting point for your implementation. It's the container for the resource adapters and a factory for other instances of the library. You should register your resource adapters before doing anything else with the API.
JsonApiResourceAdapter
The only interface in this library is the JsonApiResourceAdapter interface. The implementations of this interface converts data entries from your data model into JSON API resources. You need an instance of this interface for each data type you want to expose with your API.
JsonApiResource
The JsonApiResource class is the data container for a resource, eg a data entry from your data model. The instances of this class are set to the responding document of an API request, either as a single instance, or in an array for a collection of resources.
JsonApiDocument
The JsonApiDocument is the container of the responding document of an API request. You can set your resource(s) or error(s) as content to this document. The content of your document can even be strictly meta.
The JsonApiDocument instance holds your JsonApi instance and a JsonApiQuery instance. It's passed on to the resource adapter when converting entries into resources. Using the JsonApi instance and the JsonApiQuery, the JsonApiResourceAdapter can create the JsonApiResource instance as the client requested.
JsonApiQuery
Create a JsonApiQuery instance from your incoming query parameters. The JsonApiQuery instance will give you easy access to the requested resources and pagination, sort and filter values.
Code Sample
Process The Incoming Request
A controller for your API could be something like this:
Implement A Resource Adapter
The resource adapter for the blog posts in the previous example could be something like this:
Implementations
For more examples, you can check the following implementations of this library:
Installation
You can use Composer to install this library.