2017 © Pedro Peláez
 

library laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

image

flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  • Friday, June 29, 2018
  • by flugger
  • Repository
  • 11 Watchers
  • 371 Stars
  • 22,708 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 29 Forks
  • 11 Open issues
  • 100 Versions
  • 19 % Grown

The README.md

, (*1)

Latest Stable Version Packagist Downloads Software License Build Status Code Quality Test Coverage Donate , (*2)

Laravel Responder is a package for building API responses, integrating Fractal into Laravel and Lumen. It can transform your data using transformers, create and serialize success- and error responses, handle exceptions and assist you with testing your responses., (*3)

Table of Contents

Introduction

Laravel lets you return models directly from a controller method to convert it to JSON. This is a quick way to build APIs but leaves your database columns exposed. Fractal, a popular PHP package from The PHP League, solves this by introducing transformers. However, it can be a bit cumbersome to integrate into the framework as seen below:, (*4)

 public function index()
 {
    $resource = new Collection(User::all(), new UserTransformer());

    return response()->json((new Manager)->createData($resource)->toArray());
 }

Not that bad, but we all get a little spoiled by Laravel's magic. Wouldn't it be better if we could refactor it to:, (*5)

public function index()
{
    return responder()->success(User::all())->respond();
}

The package will allow you to do this and much more. The goal has been to create a high-quality package that feels like native Laravel. A package that lets you embrace the power of Fractal, while hiding it behind beautiful abstractions. There has also been put a lot of focus and thought to the documentation. Happy exploration!, (*6)

Requirements

This package requires: - PHP 7.0+ - Laravel 5.1+ or Lumen 5.1+, (*7)

Installation

To get started, install the package through Composer:, (*8)

composer require flugger/laravel-responder

Laravel

Register Service Provider

Append the following line to the providers key in config/app.php to register the package:, (*9)

Flugg\Responder\ResponderServiceProvider::class,

The package supports auto-discovery, so if you use Laravel 5.5 or later you may skip registering the service provider and facades as they will be registered automatically., (*10)


Register Facades (optional)

If you like facades, you may also append the Responder and Transformation facades to the aliases key:, (*11)

'Responder' => Flugg\Responder\Facades\Responder::class,
'Transformation' => Flugg\Responder\Facades\Transformation::class,

Publish Package Assets (optional)

You may additionally publish the package configuration and language file using the vendor:publish Artisan command:, (*12)

php artisan vendor:publish --provider="Flugg\Responder\ResponderServiceProvider"

This will publish a responder.php configuration file in your config folder. It will also publish an errors.php file inside your lang/en folder which can be used for storing error messages., (*13)

Lumen

Register Service Provider

Add the following line to app/bootstrap.php to register the package:, (*14)

$app->register(Flugg\Responder\ResponderServiceProvider::class);

Register Facades (optional)

You may also add the following lines to app/bootstrap.php to register the facades:, (*15)

class_alias(Flugg\Responder\Facades\Responder::class, 'Responder');
class_alias(Flugg\Responder\Facades\Transformation::class, 'Transformation');

Publish Package Assets (optional)

Seeing there is no vendor:publish command in Lumen, you will have to create your own config/responder.php file if you want to configure the package., (*16)

Usage

This documentation assumes some knowledge of how Fractal works., (*17)

Creating Responses

The package has a Responder service class, which has a success and error method to build success- and error responses respectively. To use the service and begin creating responses, pick one of the options below:, (*18)

Option 1: Inject Responder Service

You may inject the Flugg\Responder\Responder service class directly into your controller methods:, (*19)

public function index(Responder $responder)
{
    return $responder->success();
}

You can also use the error method to create error responses:, (*20)

return $responder->error();

Option 2: Use responder Helper

If you're a fan of Laravel's response helper function, you may like the responder helper function:, (*21)

return responder()->success();

```php return responder()->error();, (*22)


#### Option 3: Use `Responder` Facade Optionally, you may use the `Responder` facade to create responses: ```php return Responder::success();

```php return Responder::error();, (*23)


#### Option 4: Use `MakesResponses` Trait Lastly, the package provides a `Flugg\Responder\Http\MakesResponses` trait you can use in your controllers: ```php return $this->success();
return $this->error();

Which option you pick is up to you, they are all equivalent, the important thing is to stay consistent. The helper function (option 2) will be used for the remaining of the documentation., (*24)


Building Responses

The success and error methods return a SuccessResponseBuilder and ErrorResponseBuilder respectively, which both extend an abstract ResponseBuilder, giving them common behaviors. They will be converted to JSON when returned from a controller, but you can explicitly create an instance of Illuminate\Http\JsonResponse with the respond method:, (*25)

return responder()->success()->respond();
return responder()->error()->respond();

The status code is set to 200 by default, but can be changed by setting the first parameter. You can also pass a list of headers as the second argument:, (*26)

return responder()->success()->respond(201, ['x-foo' => true]);
return responder()->error()->respond(404, ['x-foo' => false]);

Consider always using the respond method for consistency's sake., (*27)


Casting Response Data

Instead of converting the response to a JsonResponse using the respond method, you can cast the response data to a few other types, like an array:, (*28)

return responder()->success()->toArray();
return responder()->error()->toArray();

You also have a toCollection and toJson method at your disposal., (*29)

Decorating Response

A response decorator allows for last minute changes to the response before it's returned. The package comes with two response decorators out of the box adding a status and success field to the response output. The decorators key in the configuration file defines a list of all enabled response decorators:, (*30)

'decorators' => [
    \Flugg\Responder\Http\Responses\Decorators\StatusCodeDecorator::class,
    \Flugg\Responder\Http\Responses\Decorators\SuccessFlagDecorator::class,
],

You may disable a decorator by removing it from the list, or add your own decorator extending the abstract class Flugg\Responder\Http\Responses\Decorators\ResponseDecorator. You can also add additional decorators per response:, (*31)

return responder()->success()->decorator(ExampleDecorator::class)->respond();

```php return responder()->error()->decorator(ExampleDecorator::class)->respond();, (*32)


*** The package also ships with some situational decorators disabled by default, but which can be added to the decorator list: - `PrettyPrintDecorator` decorator will beautify the JSON output; ```php \Flugg\Responder\Http\Responses\Decorators\PrettyPrintDecorator::class,
  • EscapeHtmlDecorator decorator, based on the "sanitize input, escape output" concept, will escape HTML entities in all strings returned by your API. You can securely store input data "as is" (even malicious HTML tags) being sure that it will be outputted as un-harmful strings. Note that, using this decorator, printing data as text will result in the wrong representation and you must print it as HTML to retrieve the original value.
\Flugg\Responder\Http\Responses\Decorators\EscapeHtmlDecorator::class,

Creating Success Responses

As briefly demonstrated above, success responses are created using the success method:, (*33)

return responder()->success()->respond();

Assuming no changes have been made to the configuration, the above code would output the following JSON:, (*34)

{
    "status": 200,
    "success": true,
    "data": null
}

Setting Response Data

The success method takes the response data as the first argument:, (*35)

return responder()->success(Product::all())->respond();

It accepts the same data types as you would normally return from your controllers, however, it also supports query builder and relationship instances:, (*36)

return responder()->success(Product::where('id', 1))->respond();
return responder()->success(Product::first()->shipments())->respond();

The package will run the queries and convert them to collections behind the scenes., (*37)


Transforming Response Data

The response data will be transformed with Fractal if you've attached a transformer to the response. There are two ways to attach a transformer; either explicitly by setting it on the response, or implicitly by binding it to a model. Let's look at both ways in greater detail., (*38)

Setting Transformer On Response

You can attach a transformer to the response by sending a second argument to the success method. For instance, below we're attaching a simple closure transformer, transforming a list of products to only output their names:, (*39)

return responder()->success(Product::all(), function ($product) {
    return ['name' => $product->name];
})->respond();

You may also transform using a dedicated transformer class:, (*40)

return responder()->success(Product::all(), ProductTransformer::class)->respond();
return responder()->success(Product::all(), new ProductTransformer)->respond();

You can read more about creating dedicated transformer classes in the Creating Transformers chapter., (*41)


Binding Transformer To Model

If no transformer is set, the package will search the response data for an element implementing the Flugg\Responder\Contracts\Transformable interface to resolve a transformer from. You can take use of this by implementing the Transformable interface in your models:, (*42)

class Product extends Model implements Transformable {}

You can satisfy the contract by adding a transformer method that returns the corresponding transformer:, (*43)

/**
 * Get a transformer for the class.
 *
 * @return \Flugg\Responder\Transformers\Transformer|string|callable
 */
public function transformer()
{
    return ProductTransformer::class;
}

You're not limited to returning a class name string, you can return a transformer instance or closure transformer, just like the second parameter of the success method., (*44)


Instead of implementing the Transformable contract for all models, an alternative approach is to bind the transformers using the bind method on the TransformerResolver class. You can place the code below within AppServiceProvider or an entirely new TransformerServiceProvider:, (*45)

use Flugg\Responder\Contracts\Transformers\TransformerResolver;

public function boot()
{
    $this->app->make(TransformerResolver::class)->bind([
        \App\Product::class => \App\Transformers\ProductTransformer::class,
        \App\Shipment::class => \App\Transformers\ShipmentTransformer::class,
    ]);
}

After you've bound a transformer to a model you can skip the second parameter and still transform the data:, (*46)

return responder()->success(Product::all())->respond();

As you might have noticed, unlike Fractal, you don't need to worry about creating resource objects like Item and Collection. The package will make one for you based on the data type, however, you may wrap your data in a resource object to override this., (*47)


Setting Resource Key

If the data you send into the response is a model or contains a list of models, a resource key will implicitly be resolved from the model's table name. You can overwrite this by adding a getResourceKey method to your model:, (*48)

public function getResourceKey(): string {
    return 'products';
}

You can also explicitly set a resource key on a response by sending a third argument to the ´success` method:, (*49)

return responder()->success(Product::all(), ProductTransformer::class, 'products')->respond();

Paginating Response Data

Sending a paginator to the success method will set pagination meta data and transform the data automatically, as well as append any query string parameters to the paginator links., (*50)

return responder()->success(Product::paginate())->respond();

Assuming there are no products and the default configuration is used, the JSON output would look like:, (*51)

{
    "success": true,
    "status": 200,
    "data": [],
    "pagination": {
        "total": 0,
        "count": 0,
        "perPage": 15,
        "currentPage": 1,
        "totalPages": 1,
        "links": []
    }
}

Setting Paginator On Response

Instead of sending a paginator as data, you may set the data and paginator seperately, like you traditionally would with Fractal. You can manually set a paginator using the paginator method, which expects an instance of League\Fractal\Pagination\IlluminatePaginatorAdapter:, (*52)

$paginator = Product::paginate();
$adapter = new IlluminatePaginatorAdapter($paginator);

return responder()->success($paginator->getCollection())->paginator($adapter)->respond();

Setting Cursor On Response

You can also set cursors using the cursor method, expecting an instance of League\Fractal\Pagination\Cursor:, (*53)

if ($request->has('cursor')) {
    $products = Product::where('id', '>', request()->cursor)->take(request()->limit)->get();
} else {
    $products = Product::take(request()->limit)->get();
}

$cursor = new Cursor(request()->cursor, request()->previous, $products->last()->id ?? null, Product::count());

return responder()->success($products)->cursor($cursor)->respond();

Including Relationships

If a transformer class is attached to the response, you can include relationships using the with method:, (*54)

return responder()->success(Product::all())->with('shipments')->respond();

You can send multiple arguments and specify nested relations using dot notation:, (*55)

return responder()->success(Product::all())->with('shipments', 'orders.customer')->respond();

All relationships will be automatically eager loaded, and just like you would when using with or load to eager load with Eloquent, you may use a callback to specify additional query constraints. Like in the example below, where we're only including related shipments that hasn't yet been shipped:, (*56)

return responder()->success(Product::all())->with(['shipments' => function ($query) {
    $query->whereNull('shipped_at');
}])->respond();

Including From Query String

Relationships are loaded from a query string parameter if the load_relations_parameter configuration key is set to a string. By default, it's set to with, allowing you to automatically include relations from the query string:, (*57)

GET /products?with=shipments,orders.customer

Excluding Default Relations

In your transformer classes, you may specify relations to automatically load. You may disable any of these relations using the without method:, (*58)

return responder()->success(Product::all())->without('comments')->respond();

Filtering Transformed Data

The technique of filtering the transformed data to only return what we need is called sparse fieldsets and can be specified using the only method:, (*59)

return responder()->success(Product::all())->only('id', 'name')->respond();

When including relationships, you may also want to filter fields on related resources as well. This can be done by instead specifying an array where each key represents the resource keys for the resources being filtered, (*60)

return responder()->success(Product::all())->with('shipments')->only([
    'products' => ['id', 'name'],
    'shipments' => ['id']
])->respond();

Filtering From Query String

Fields will automatically be filtered if the filter_fields_parameter configuration key is set to a string. It defaults to only, allowing you to filter fields from the query string:, (*61)

GET /products?only=id,name

You may automatically filter related resources by setting the parameter to a key-based array:, (*62)

GET /products?with=shipments&only[products]=id,name&only[shipments]=id

Adding Meta Data

You may want to attach additional meta data to your response. You can do this using the meta method:, (*63)

return responder()->success(Product::all())->meta(['count' => Product::count()])->respond();

When using the default serializer, the meta data will simply be appended to the response array:, (*64)

{
    "success": true,
    "status": 200,
    "data": [],
    "count": 0
}

Serializing Response Data

After the data has been transformed, it will be serialized using the specified success serializer in the configuration file, which defaults to the package's own Flugg\Responder\Serializers\SuccessSerializer. You can overwrite this on your responses using the serializer method:, (*65)

return responder()->success()->serializer(JsonApiSerializer::class)->respond();
return responder()->success()->serializer(new JsonApiSerializer())->respond();

Above we're using Fractal's JsonApiSerializer class. Fractal also ships with an ArraySerializer and DataArraySerializer class. If none of these suit your taste, feel free to create your own serializer by extending League\Fractal\Serializer\SerializerAbstract. You can read more about it in Fractal's documentation., (*66)

Creating Transformers

A dedicated transformer class gives you a convenient location to transform data and allows you to reuse the transformer at multiple places. It also allows you to include and transform relationships. You can create a transformer using the make:transformer Artisan command:, (*67)

php artisan make:transformer ProductTransformer

The command will generate a new ProductTransformer.php file in the app/Transformers folder:, (*68)

<?php

namespace App\Transformers;

use App\User;
use Flugg\Responder\Transformers\Transformer;

class ProductTransformer extends Transformer
{
    /**
     * List of available relations.
     *
     * @var string[]
     */
    protected $relations = [];

    /**
     * A list of autoloaded default relations.
     *
     * @var array
     */
    protected $load = [];

    /**
     * Transform the model.
     *
     * @param  \App\Product $product
     * @return array
     */
    public function transform(Product $product): array
    {
        return [
            'id' => (int) $product->id,
        ];
    }
}

It will automatically resolve a model name from the name provided. For instance, the package will extract Product from ProductTransformer and assume the models live directly in the app folder (as per Laravel's convention). If you store them somewhere else, you can use the --model (or -m) option to override it:, (*69)

php artisan make:transformer ProductTransformer --model="App\Models\Product"

Creating Plain Transformers

The transformer file generated above is a model transformer expecting an App\Product model for the transform method. However, we can create a plain transformer by applying the --plain (or -p) modifier:, (*70)

php artisan make:transformer ProductTransformer --plain

This will remove the typehint from the transform method and add less boilerplate code., (*71)

Setting Relationships

The $relations and $load properties in the transformer are the equivalent to Fractal's own $availableIncludes and $defaultIncludes. In addition to the slight name change, the package uses the $relations and $load properties to map out all available relationships for eager loading, so in contrast to Fractal, you should map the relationship to their corresponding transformer:, (*72)

protected $relations = [
    'shipments' => ShipmentTransformer::class,
];

You can choose to skip the mapping and just pass the strings like with Fractal, but that means the package wont be able to eager load relationships automatically., (*73)


Setting Whitelisted Relationships

The $relations property specifies a list of relations available to be included. You can set a list of relations mapped to their corresponding transformers:, (*74)

protected $relations = [
    'shipments' => ShipmentTransformer::class,
    'orders' => OrderTransformer::class,
];

Setting Autoloaded Relationships

The $load property specifies a list of relations to be autoloaded every time you transform data with the transformer:, (*75)

protected $load = [
    'shipments' => ShipmentTransformer::class,
    'orders' => OrderTransformer::class,
];

You don't have to add relations to both $relations and $load, all relations in $load will be available by nature., (*76)


Including Relationships

While Fractal requires you to to create a method in your transformer for every included relation, this package lets you skip this when transforming models, as it will automatically fetch relationships from the model. You may of course override this functionality by creating an "include" method:, (*77)

/**
 * Include related shipments.
 *
 * @param  \App\Product $product
 * @return mixed
 */
public function includeShipments(Product $product)
{
    return $product->shipments;
}

Unlike Fractal you can just return the data directly without wrapping it in an item or collection method., (*78)


You should be careful with executing database calls inside the include methods as you might end up with an unexpected amount of hits to the database., (*79)


Using Include Parameters

Fractal can parse query string parameters which can be used when including relations. For more information about how to format the parameters see Fractal's documentation on parameters. You may access the parameters by adding a second parameter to the "include" method:, (*80)

public function includeShipments(Product $product, Collection $parameters)
{
    return $product->shipments->take($parameters->get('limit'));
}

To be as decoupled from Fractal as possible the parameters (which are normally accessed using League\Fractal\ParamBag) are accessed as Laravel collections instead., (*81)


Adding Query Constraints

Just as you can specify a query constraint when including a relationship with the with method, you can also add query constraints as a "load" method on the transformer. This will automatically be applied when extracting relationships for eager loading., (*82)

/**
 * Load shipments with constraints.
 *
 * @param  \Illuminate\Database\Eloquent\Builder $query
 * @return \Illuminate\Database\Eloquent\Builder
 */
public function loadShipments($query)
{
    return $query->whereNull('shipped_at');
}

Note: You cannot mix "include" and "load" methods because the package doesn't eager load relationships included with an "include" method., (*83)


Filtering Relationships

After a relation has been included, you can make any last second changes to it using a filter method. For instance, below we're filtering the list of related shipments to only include shipments that has not been shipped:, (*84)

/**
 * Filter included shipments.
 *
 * @param  \Illuminate\Database\Eloquent\Collection $shipments
 * @return \Illuminate\Support\Collection
 */
public function filterShipments($shipments)
{
    return $shipments->filter(function ($shipment) {
        return is_null($shipment->shipped_at);
    });
}

Transforming Data

We've looked at how to transform response data of success responses, however, there may be other places than your controllers where you want to transform data. An example is broadcasted events where you're exposing data using websockets instead of HTTP. You just want to return the transformed data, not an entire response., (*85)

It's possible to simply transform data by newing up the transformer and calling transform:, (*86)

return (new ProductTransformer)->transform(Product::first());

However, this approach might become a bit messy when building transformations with relationships:, (*87)

return array_merge((new ProductTransformer)->transform($product = Product::first()), [
    'shipments' => $product->shipments->map(function ($shipment) {
        return (new ShipmentTransformer)->transform($shipment);
    })
]);

Yuck! Imagine that with multiple nested relationships. Let's explore a simpler way to handle this., (*88)

Building Transformations

The SuccessResponseBuilder actually delegates all of the transformation work to a dedicated Flugg\Responder\TransformBuilder class. We can use this class ourself to transform data. For instance, if the product and shipment transformers were bound to the models, we could replicate the code above in the following way:, (*89)

public function index(TransformBuilder $transformation)
{
    return $transformation->resource(Product::all())->with('shipments')->transform();
}

Instead of using the success method on the Responder service, we use the resource method on the TransformBuilder with the same method signature. We also use transform to execute the transformation instead of respond as we did when creating responses. In addition to the with method, you also have access to the other transformation methods like without, only, meta and serializer., (*90)


Using toArray on the Responder service is almost the same as the code above, however, it will also include response decorators which might not be desired., (*91)


Transforming Without Serializing

When using the TransformBuilder to transform data it will still serialize the data using the configured serializer. Fractal requires the use of a serializer to transform data, but sometimes we're just interested in the raw transformed data. The package ships with a Flugg\Responder\Serializers\NoopSerializer to solve this, a no-op serializer which leaves the transformed data untouched:, (*92)

return $transformation->resource(Product::all())->serializer(NoopSerializer::class)->transform();

If you think this is looking messy, don't worry, there's a quicker way. In fact, you will probably never even need to utilize the NoopSerializer or TransformBuilder manually, but it helps to know how it works. The Flugg\Responder\Transformation is a class which can be used for quickly transforming data without serializing., (*93)

Option 1: The Transformation Service

The Transformation class utilizes the TransformBuilder class to build a transformation using the NoopSerializer. You can inject the Transformation class and call make to obtain an instance of TransformBuilder which gives you access to all of the chainable methods including with, like below:, (*94)

public function __construct(Transformation $transformation)
{
    $transformation->make(Product::all())->with('shipments')->transform();
}

Option 2: The transformation Helper

You can use the transformation helper function to transform data without serializing:, (*95)

transformation(Product::all())->with('shipments')->transform();

Option 3: The Transformation Facade

You can also use the Transformation facade to achieve the same thing:, (*96)

Transformation::make(Product::all())->with('shipments')->transform();

Transforming To Camel Case

Model attributes are traditionally specified in snake case, however, you might prefer to use camel case for the response fields. A transformer makes for a perfect location to convert the fields, as seen from the soldOut field in the example below:, (*97)

return responder()->success(Product::all(), function ($product) {
    return ['soldOut' => (bool) $product->sold_out];    
})->respond();

Transforming Request Parameters

After responding with camel case, you probably want to let people send in request data using camel cased parameters as well. The package provides a Flugg\Responder\Http\Middleware\ConvertToSnakeCase middleware you can append to the $middleware array in app/Http/Kernel.php to convert all parameters to snake case automatically:, (*98)

protected $middleware = [
    // ...
    \Flugg\Responder\Http\Middleware\ConvertToSnakeCase::class,
];

The middleware will run before request validation, so you should specify your validation rules in snake case as well., (*99)


Creating Error Responses

Whenever a consumer of your API does something unexpected, you can return an error response describing the problem. As briefly shown in a previous chapter, an error response can be created using the error method:, (*100)

return responder()->error()->respond();

The error response has knowledge about an error code, a corresponding error message and optionally some error data. With the default configuration, the above code would output the following JSON:, (*101)

{
    "success": false,
    "status": 500,
    "error": {
        "code": null,
        "message": null
    }
}

Setting Error Code & Message

You can fill the first parameter of the error method to set an error code:, (*102)

return responder()->error('sold_out_error')->respond();

You may optionally use integers for error codes., (*103)


In addition, you may set the second parameter to an error message describing the error:, (*104)

return responder()->error('sold_out_error', 'The requested product is sold out.')->respond();

Set Messages In Language Files

You can set the error messages in a language file, which allows for returning messages in different languages. The configuration file has an error_message_files key defining a list of language files with error messages. By default, it is set to ['errors'], meaning it will look for an errors.php file inside resources/lang/en. You can use these files to map error codes to corresponding error messages:, (*105)

return [
    'sold_out_error' => 'The requested product is sold out.',
];

Register Messages Using ErrorMessageResolver

Instead of using language files, you may alternatively set error messages directly on the ErrorMessageResolver class. You can place the code below within AppServiceProvider or an entirely new TransformerServiceProvider:, (*106)

use Flugg\Responder\ErrorMessageResolver;

public function boot()
{
    $this->app->make(ErrorMessageResolver::class)->register([
        'sold_out_error' => 'The requested product is sold out.',
    ]);
}

Adding Error Data

You may want to set additional data on the error response. Like in the example below, we're returning a list of shipments with the sold_out error response, giving the consumer information about when a new shipment for the product might arrive., (*107)

return responder()->error('sold_out')->data(['shipments' => Shipment::all()])->respond();

The error data will be appended to the response data. Assuming we're using the default serializer and there are no shipments in the database, the code above would look like:, (*108)

{
    "success": false,
    "status": 500,
    "error": {
        "code": "sold_out",
        "message": "The requested product is sold out.",
        "shipments": []
    }
}

Serializing Response Data

Similarly to success responses, error responses will be serialized using the specified error serializer in the configuration file. This defaults to the package's own Flugg\Responder\Serializers\ErrorSerializer, but can of course be changed by using the serializer method:, (*109)

return responder()->error()->serializer(ExampleErrorSerializer::class)->respond();
return responder()->success()->serializer(new ExampleErrorSerializer())->respond();

You can create your own error serializer by implementing the Flugg\Responder\Contracts\ErrorSerializer contract., (*110)

Handling Exceptions

No matter how much we try to avoid them, exceptions do happen. Responding to the exceptions in an elegant manner will improve the user experience of your API. The package can enhance your exception handler to automatically turn exceptions in to error responses. If you want to take use of this, you can either use the package's exception handler or include a trait as described in further details below., (*111)

Option 1: Replace Handler Class

To use the package's exception handler you need to replace the default import in app/Exceptions/Handler.php:, (*112)

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

With the package's handler class:, (*113)

use Flugg\Responder\Exceptions\Handler as ExceptionHandler;

This will not work with Lumen as its exception handler is incompatible with Laravel's. Look instead at the second option below., (*114)


Option 2: Use ConvertsExceptions Trait

The package's exception handler uses the Flugg\Responder\Exceptions\ConvertsExceptions trait to load of most of its work. Instead of replacing the exception handler, you can use the trait in your own handler class. To replicate the behavior of the exception handler, you would also have to add the following code to the render method:, (*115)

public function render($request, Exception $exception)
{
    $this->convertDefaultException($exception);

    if ($exception instanceof HttpException) {
        return $this->renderResponse($exception);
    }

    return parent::render($request, $exception);
}

If you only want to return JSON error responses on requests actually asking for JSON, you may wrap the code above in a wantsJson check as seen below:, (*116)

if ($request->wantsJson()) {
    $this->convertDefaultException($exception);

    if ($exception instanceof HttpException) {
        return $this->renderResponse($exception);
    }
}

Converting Exceptions

Once you've implemented one of the above options, the package will convert some of Laravel's exceptions to an exception extending Flugg\Responder\Exceptions\Http\HttpException. It will then convert these to an error response. The table below shows which Laravel exceptions are converted and what they are converted to. All the exceptions on the right is under the Flugg\Responder\Exceptions\Http namespace and extends Flugg\Responder\Exceptions\Http\HttpException. All exceptions extending the HttpException class will be automatically converted to an error response., (*117)

Caught Exceptions Converted To
Illuminate\Auth\AuthenticationException UnauthenticatedException
Illuminate\Auth\Access\AuthorizationException UnauthorizedException
Symfony\Component\HttpKernel\Exception\NotFoundHttpException PageNotFoundException
Illuminate\Database\Eloquent\ModelNotFoundException PageNotFoundException
Illuminate\Database\Eloquent\RelationNotFoundException RelationNotFoundException
Illuminate\Validation\ValidationException ValidationFailedException

You can disable the conversions of some of the exceptions above using the $dontConvert property:, (*118)

/**
 * A list of default exception types that should not be converted.
 *
 * @var array
 */
protected $dontConvert = [
    ModelNotFoundException::class,
];

If you're using the trait option, you can disable all the default conversions by removing the call to convertDefaultException in the render method., (*119)


Convert Custom Exceptions

In addition to letting the package convert Laravel exceptions, you can also convert your own exceptions using the convert method in the render method:, (*120)

$this->convert($exception, [
    InvalidValueException => PageNotFoundException,
]);

You can optionally give it a closure that throws the new exception, if you want to give it constructor parameters:, (*121)

$this->convert($exception, [
    MaintenanceModeException => function ($exception) {
        throw new ServerDownException($exception->retryAfter);
    },
]);

Creating HTTP Exceptions

An exception class is a convenient place to store information about an error. The package provides an abstract exception class Flugg\Responder\Exceptions\Http\HttpException, which has knowledge about status code, an error code and an error message. Continuing on our product example from above, we could create our own HttpException class:, (*122)

<?php

namespace App\Exceptions;

use Flugg\Responder\Exceptions\Http\HttpException;

class SoldOutException extends HttpException
{
    /**
     * The HTTP status code.
     *
     * @var int
     */
    protected $status = 400;

    /**
     * The error code.
     *
     * @var string|null
     */
    protected $errorCode = 'sold_out_error';

    /**
     * The error message.
     *
     * @var string|null
     */
    protected $message = 'The requested product is sold out.';
}

You can also add a data method returning additional error data:, (*123)

/**
 * Retrieve additional error data.
 *
 * @return array|null
 */
public function data()
{
    return [
        'shipments' => Shipment::all()
    ];
}

If you're letting the package handle exceptions, you can now throw the exception anywhere in your application and it will automatically be rendered to an error response., (*124)

throw new SoldOutException();

Contributing

Contributions are more than welcome and you're free to create a pull request on Github. You can run tests with the following command:, (*125)

vendor/bin/phpunit

If you find bugs or have suggestions for improvements, feel free to submit an issue on Github. However, if it's a security related issue, please send an email to flugged@gmail.com instead., (*126)

Donating

The package is completely free to use, however, a lot of time has been put into making it. If you want to show your appreciation by leaving a small donation, you can do so by clicking here. Thanks!, (*127)

License

Laravel Responder is free software distributed under the terms of the MIT license. See license.md for more details., (*128)

The Versions

29/06 2018
06/02 2018

v3.0.1

3.0.1.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

28/01 2018

v3.0.0

3.0.0.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

24/01 2018

v2.0.14

2.0.14.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

23/01 2018

v2.0.13

2.0.13.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

17/10 2017

v2.0.12

2.0.12.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

23/09 2017

v2.0.11

2.0.11.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

17/09 2017

v2.0.10

2.0.10.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

02/09 2017

v2.0.9

2.0.9.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

24/08 2017

dev-dev

dev-dev https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

17/08 2017

v2.0.8

2.0.8.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

17/08 2017

v2.0.7

2.0.7.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

16/08 2017

v2.0.6

2.0.6.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

16/08 2017

v2.0.5

2.0.5.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

15/08 2017

dev-feature-resolve-resource-key

dev-feature-resolve-resource-key https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

15/08 2017

v2.0.4

2.0.4.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

11/08 2017

v2.0.3

2.0.3.0 https://github.com/flugger/laravel-responder

A Laravel Fractal package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

11/08 2017

v2.0.2

2.0.2.0 https://github.com/flugger/laravel-responder

A Fractal Laravel package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

11/08 2017

v2.0.1

2.0.1.0 https://github.com/flugger/laravel-responder

A Fractal Laravel package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

08/08 2017

v2.0.0

2.0.0.0 https://github.com/flugger/laravel-responder

A Fractal Laravel package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

08/08 2017

v2.x-dev

2.9999999.9999999.9999999-dev https://github.com/flugger/laravel-responder

A Fractal Laravel package for building API responses, giving you the power of Fractal and the elegancy of Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api lumen response fractal transformer responder

18/06 2017

v1.2.25

1.2.25.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

13/05 2017

v1.2.24

1.2.24.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

30/04 2017

v1.2.23

1.2.23.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

25/04 2017

v1.2.22

1.2.22.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

03/03 2017

v1.2.21

1.2.21.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

22/02 2017

v1.2.20

1.2.20.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

26/01 2017

v1.2.19

1.2.19.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

16/01 2017

v1.2.18

1.2.18.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

10/12 2016

v1.2.17

1.2.17.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

18/11 2016

v1.2.16

1.2.16.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

04/11 2016

v1.2.15

1.2.15.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

03/11 2016

v1.2.14

1.2.14.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

01/11 2016

v1.2.13

1.2.13.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

01/11 2016

v1.2.12

1.2.12.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

31/10 2016

v1.2.11

1.2.11.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

31/10 2016

v1.2.10

1.2.10.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

31/10 2016

v1.2.9

1.2.9.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

30/10 2016

v1.2.8

1.2.8.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

14/10 2016

v1.2.7

1.2.7.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

05/10 2016

v1.2.6

1.2.6.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

21/09 2016

v1.2.5

1.2.5.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

03/09 2016

v1.2.4

1.2.4.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

31/08 2016

v1.2.3

1.2.3.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

31/08 2016

v1.2.2

1.2.2.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

30/08 2016

v1.2.1

1.2.1.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

30/08 2016

v1.2.0

1.2.0.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

28/08 2016

v1.1.3

1.1.3.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json lumen response fractal transformer responder

26/07 2016

v1.1.2

1.1.2.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

25/07 2016

v1.1.1

1.1.1.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

25/07 2016

v1.0.18

1.0.18.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

25/07 2016

v1.1.0

1.1.0.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

25/07 2016

v1.0.17

1.0.17.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

21/07 2016

v1.0.16

1.0.16.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

21/07 2016

v1.0.15

1.0.15.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

20/07 2016

v1.0.14

1.0.14.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

20/07 2016

v1.0.13

1.0.13.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

20/07 2016

v1.0.12

1.0.12.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

20/07 2016

v1.0.11

1.0.11.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api json response transformers fractal responder

18/07 2016

v1.0.10

1.0.10.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

18/07 2016

v1.0.9

1.0.9.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

18/07 2016

v1.0.8

1.0.8.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

18/07 2016

v1.0.7

1.0.7.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

18/07 2016

v1.0.6

1.0.6.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

17/07 2016

v1.0.5

1.0.5.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

14/07 2016

v1.0.4

1.0.4.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

14/07 2016

v1.0.3

1.0.3.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

14/07 2016

v1.0.2

1.0.2.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

14/07 2016

v1.0.1

1.0.1.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

14/07 2016

v1.0.0

1.0.0.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

14/07 2016

v0.3.0

0.3.0.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

14/07 2016

v0.2.26

0.2.26.0 https://github.com/flugger/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

13/07 2016

v0.2.25

0.2.25.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

13/07 2016

v0.2.24

0.2.24.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

13/07 2016

v0.2.23

0.2.23.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

11/07 2016

v0.2.22

0.2.22.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

11/07 2016

v0.2.21

0.2.21.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

11/07 2016

v0.2.20

0.2.20.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

11/07 2016

v0.2.19

0.2.19.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

08/07 2016

v0.2.18

0.2.18.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

07/07 2016

v0.2.17

0.2.17.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

05/07 2016

v0.2.16

0.2.16.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

05/07 2016

v0.2.15

0.2.15.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

05/07 2016

v0.2.14

0.2.14.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

04/07 2016

v0.2.13

0.2.13.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

28/06 2016

v0.2.12

0.2.12.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

28/06 2016

v0.2.11

0.2.11.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

28/06 2016

v0.2.10

0.2.10.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

27/06 2016

v0.2.9

0.2.9.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

27/06 2016

v0.2.8

0.2.8.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

27/06 2016

v0.2.7

0.2.7.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

27/06 2016

v0.2.6

0.2.6.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

27/06 2016

v0.2.5

0.2.5.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

27/06 2016

v0.2.4

0.2.4.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

26/06 2016

v0.2.3

0.2.3.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

26/06 2016

v0.2.2

0.2.2.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

26/06 2016

v0.2.1

0.2.1.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

26/06 2016

v0.2.0

0.2.0.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder

26/06 2016

v0.1.9

0.1.9.0 https://github.com/mangopixel/laravel-responder

A Laravel package for APIs, wrapping the Fractal library behind an elegant Laravel API.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexander Tømmerås

laravel api response transformers fractal responder