PHPackages                             lykegenes/laravel-api-response - 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. lykegenes/laravel-api-response

ActiveLibrary[API Development](/categories/api)

lykegenes/laravel-api-response
==============================

A Laravel wrapper for thephpleague's Fractal package

1.2.0(10y ago)31862MITPHPCI failing

Since Sep 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Lykegenes/laravel-api-response)[ Packagist](https://packagist.org/packages/lykegenes/laravel-api-response)[ Docs](https://github.com/lykegenes/laravel-api-response)[ RSS](/packages/lykegenes-laravel-api-response/feed)WikiDiscussions master Synced 1mo ago

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

laravel-api-response
====================

[](#laravel-api-response)

[![Latest Version on Packagist](https://camo.githubusercontent.com/afa6162eb24e6017ae2f942647438501f254fc83ee9b0edc44ac62226aaa3966/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c796b6567656e65732f6c61726176656c2d6170692d726573706f6e73652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lykegenes/laravel-api-response)[![Software License](https://camo.githubusercontent.com/ff86f8053bf82d04bc4924d5bff28d9c279b18ec2d6e73dc719391e1124ba6c4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c796b6567656e65732f6c61726176656c2d6170692d726573706f6e73652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e064dc9a45f3782307e29bcd29fddd7c3faf312fcf0e262a0f79bb034fc5a425/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4c796b6567656e65732f6c61726176656c2d6170692d726573706f6e73652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Lykegenes/laravel-api-response)[![Coverage Status](https://camo.githubusercontent.com/cb5e31d99c0034a36230fa439ec61adbd5cf350ac134cd4adc84ff38d304eaa6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c796b6567656e65732f6c61726176656c2d6170692d726573706f6e73652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/lykegenes/laravel-api-response/code-structure)[![Quality Score](https://camo.githubusercontent.com/a6365d5e8b7f5f5993072e5f9c358ab235ce35775a96ef1814c62c7756dad28d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c796b6567656e65732f6c61726176656c2d6170692d726573706f6e73652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/lykegenes/laravel-api-response)[![Total Downloads](https://camo.githubusercontent.com/e2fbd6600a5c4f7c1e5055b1b431f954e8e4eb880942ecde0ced1df62ebbc29a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c796b6567656e65732f6c61726176656c2d6170692d726573706f6e73652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lykegenes/laravel-api-response)

A Laravel wrapper for thephpleague's Fractal package

Install
-------

[](#install)

Via Composer

```
composer require lykegenes/laravel-api-response
```

Then, add this to your Service Providers :

```
Lykegenes\ApiResponse\ServiceProvider::class,
```

...and this to your Aliases :

```
'ApiResponse' => Lykegenes\ApiResponse\Facades\ApiResponse::class,
```

Optionally, you can publish and edit the configuration file :

```
php artisan vendor:publish --provider="Lykegenes\ApiResponse\ServiceProvider" --tag=config
```

Usage
-----

[](#usage)

The easiest way to use this package is to call the **make()** function from the facade. It will try to guess your input. For the transformers, see the docs from the Fractal package [here](http://fractal.thephpleague.com/transformers/).

```
// You can use a class directly to return a paginated collection
return ApiResponse::make(User::class, UserTransformer::class);

// You can also use an Eloquent Query
return ApiResponse::make(User::where('age', '
