Helps building nice, normalized and easy to consume Laravel REST API.
truegameover/laravel-api-response-builder is a Laravel package for helps building nice, normalized and easy to consume laravel rest api..
It currently has 0 GitHub stars and 10 downloads on Packagist (latest version 1.0.4).
Install it with composer require truegameover/laravel-api-response-builder.
Discover more Laravel packages by truegameover
or browse all Laravel packages to compare alternatives.
Last updated

Upgrading from previous version? Check compatibility docs prior altering your composer.json!
ResponseBuilder is a Laravel helper designed to build nice, normalized and easy to consume REST API
JSON responses.
ResponseBuilder is written for REST API developers by REST API developer and is based on my long lasting experience on both
"sides" (API dev and API consumer) of variety of REST APIs. Lightweight, with simple to use public methods, covering multiple
potential use-cases, on-the-fly data conversion, localization support, automatic error message building, support
for chained APIs and (hopefully) exhaustive documentation. But that's not all! The JSON structure produced by ResponseBuilder
is designed with users of your API in mind, which helps them easily deal with your API with ease. They get simple, well
defined and predictable JSON structure responses with all the fields needed to consume it without any unnecessary a hassle nor
other trickery.
Android developers can use ApiResponse library to handle ResponseBuilder
responses produced in their mobile applications.
You are even covered in a case of emergency as provided Exception Handler ensures your API keeps talking JSON (and not HTML) to its clients if case of any unexpected and unhandled exception.
Did I mention, you also get testing traits that would automatically cover your whole ResponseBuilder related code with
unit tests with just a few lines of code?
Operation successful? Conclude your controller method with:
return ResponseBuilder::success();
and your client will get nice JSON like
{
"success": true,
"code": 0,
"locale": "en",
"message": "OK",
"data": null
}
Something went wrong? Just type:
return ResponseBuilder::error(250);
The following JSON response will then be returned:
{
"success": false,
"code": 250,
"locale": "en",
"message": "Your error message for code 250",
"data": null
}
Nice and easy! And yes, message can be easily customized! Also there're much, much more you can do with
rich ResponseBuilder API. See library documentation for details and more examples!