PHPackages                             felipe-douradinho/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. felipe-douradinho/laravel-jsonapi

ActiveLibrary[API Development](/categories/api)

felipe-douradinho/laravel-jsonapi
=================================

37PHP

Since Sep 14Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

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

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

[![Build Status](https://camo.githubusercontent.com/a9a98ef6305cafa5547b63d563801e3516dd3d230742dd426a9eac53289d1f4a/68747470733a2f2f7472617669732d63692e6f72672f46656c697065446f75726164696e686f2f6c61726176656c2d6a736f6e6170692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/FelipeDouradinho/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 `felipe-douradinho/laravel-jsonapi` to your composer.json dependency list
2. Run `composer update`.

### Requirements

[](#requirements)

- PHP 5.4+
- Laravel 5.1.\*

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.

    ```
