PHPackages                             earthling-interactive/laravel-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. earthling-interactive/laravel-jsonapi

ActiveLibrary[API Development](/categories/api)

earthling-interactive/laravel-jsonapi
=====================================

v6.0.2(11y ago)12132[3 issues](https://github.com/EarthlingInteractive/laravel-jsonapi/issues)MITPHPPHP &gt;=5.4.0

Since Jul 22Pushed 11y ago16 watchersCompare

[ Source](https://github.com/EarthlingInteractive/laravel-jsonapi)[ Packagist](https://packagist.org/packages/earthling-interactive/laravel-jsonapi)[ RSS](/packages/earthling-interactive-laravel-jsonapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (5)Versions (35)Used By (0)

JSON API helpers for Laravel 5
==============================

[](#json-api-helpers-for-laravel-5)

[![Build Status](https://camo.githubusercontent.com/36f2fd8cce19541ee056bc94ac70385bd820e4ba83c9c74e04ef69e4e02591e4/68747470733a2f2f7472617669732d63692e6f72672f45617274686c696e67496e7465726163746976652f6c61726176656c2d6a736f6e6170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/EarthlingInteractive/laravel-jsonapi)

Make it a breeze to create a [jsonapi.org](http://jsonapi.org/) RC3 compliant API with Laravel 5.

Code forked from echo-it/laravel-jsonapi project by Ronni Egeriis Persson.

Installation
------------

[](#installation)

1. Add `earthling-interactive/laravel-jsonapi` to your composer.json dependency list
2. Run `composer update`.

### Requirements

[](#requirements)

- PHP 5.4+
- Laravel 5

Using laravel-jsonapi
---------------------

[](#using-laravel-jsonapi)

This library is made with the concept of exposing models in mind, as found in the RESTful API approach.

In few steps you can expose your models:

1. **Create a route to direct the requests**

    In this example, we use a route for any OPTION requests, a generic route for interacting with resources, and another route for interacting with resource relationships:

    ```
    Route::options('api/{model}/{id?}', 'ApiController@handleRequest');
    Route::any('api/{model}/{id?}', 'ApiController@handleRequest');
    Route::any('api/{model}/{id}/links/{relation}', 'ApiController@handleRequest');
    ```
2. **Create your controller to handle the request**

    Your controller is responsible to handling input, instantiating a handler class and returning the response.

    ```
