Laravel API Responder is a package for making API responses, integrating Fractal into Laravel and Lumen. It can modify your data using transformers, formulate and serialize success- and error responses, handle exceptions. It also helps you with testing your responses.
Introduction
When creating powerful APIs, you want to make sure your endpoints are compatible and easy to use by your application. Laravel is pertinent for your API, however, it lacks support for general tools like transformers and serializers. Yet Fractal has some great tools for building APIs and fills in the gaps of Laravel.
While Fractal resolves many of the lapses of Laravel. It’s usually a bit complex to integrate into the framework.
Requirements
This package requires:
-
PHP 7.0+
-
Laravel 5.1+ or Lumen 5.1+
Installation
To get started, install the package through Composer:
composer require flugger/laravel-responder
Registering the Service Provider
After updating the composer, you’ve to add the following service provider to the providers key in config/app.php:
Flugg\Responder\ResponderServiceProvider::class
Registering the Facade
If you like facades, you can also add the Responder facade to the aliases key:
'Responder' => Flugg\Responder\Facades\Responder::class
Publishing Package Assets
You may also publish the package configuration and language file utilizing the Artisan command:
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 is used to save your error messages.
Usage
The package has a Flugg\Responder\Responder service which is capable of building success and error responses for your API.
For more details, you can see full documentation here.
flugg / laravel-responder