New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

plata/fravel

A Fractal wrapper for Laravel
553
Install
composer require plata/fravel
Latest Version:v1.1.2
PHP:>=5.3.0
License:MIT
Last Updated:Sep 15, 2017
Links: GitHub  ·  Packagist
Maintainer: silverxjohn

Fravel

License

A Fractal wrapper for Laravel

Fractal is designed in such a way that it could be used by any frameworks or no framework at all. But wouldn't it be cool if we can use it like it's build right on top of Laravel?

Installation

Composer

composer require plata/fravel

Then in your config/app.php's provider array:

'providers' => [
  // ...
  'Plata\Fravel\FravelServiceProvider::class',
  // ...
]

and within the same file,

'aliases' => [
  // ...
  ''Fractal' => \Plata\Fravel\Facade\Fractal::class',
  // ...
]

Usage

For a collection of resource,

$resource = Fractal::collection(User::all(), $transformer);

return Response::fractal($resource);

For a single resource,

$resource = Fractal::item(User::find(1), $transformer);

return Response::fractal($resource);

Generators

Everyone knows that developers doesn't like repetitive tasks. That's why generators are really helpful for creating a base template for you!

Transformers

Existing Model and Migration

php artisan make:transformer UserTransformer

For non existing model/migration, just append -t flag

php artisan make:model User -m -t

Configurations

Fravel ships with a configuration file where you can change any Fractal specific behaviour. Just run:

php artisan vendor:publish

Support

Need more control? Check this thorough documentation of Fravel.

Related Packages

ellipsesynergie/api-response

Simple package to handle response properly in your API

1,436,195 371
ricktap/autobot

Automatic transformation with league/fractal. Translates your Laravel 5 collecti...

5 0
cyvelnet/laravel5-fractal

A simple fractal service provider and transformer generator with model attribute...

190,292 79
viodev/laravel-replier

Laravel package for making JSON APIs.

16,385 1
yadakhov/json

A simple wrapper class to work with json in PHP.

8,393 16

Version History

Version Released PHP License
v1.1.2 >=5.3.0 MIT
v1.1.1 >=5.3.0 MIT
v1.1.0 >=5.3.0 MIT
v1.0 MIT