PHPackages                             ride/lib-http-jsonapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ride/lib-http-jsonapi

ActiveLibrary[API Development](/categories/api)

ride/lib-http-jsonapi
=====================

JSON API library of the Ride framework

1.2.0(1y ago)02.6k1[1 PRs](https://github.com/all-ride/ride-lib-http-jsonapi/pulls)5MITPHP

Since Aug 5Pushed 1y ago11 watchersCompare

[ Source](https://github.com/all-ride/ride-lib-http-jsonapi)[ Packagist](https://packagist.org/packages/ride/lib-http-jsonapi)[ RSS](/packages/ride-lib-http-jsonapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (15)Used By (5)

Ride: JSON API Library
======================

[](#ride-json-api-library)

JSON API library of the PHP Ride framework.

Check  for a full reference of the standard.

What's In This Library?
-----------------------

[](#whats-in-this-library)

### JsonApi

[](#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

[](#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

[](#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

[](#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

[](#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
-----------

[](#code-sample)

### Process The Incoming Request

[](#process-the-incoming-request)

A controller for your API could be something like this:

```
