A laravel package for easily build json api response.
juanyaolin/laravel-api-response-builder is a Laravel package for a laravel package for easily build json api response..
It currently has 1 GitHub stars and 9 downloads on Packagist (latest version 1.0.1).
Install it with composer require juanyaolin/laravel-api-response-builder.
Discover more Laravel packages by juanyaolin
or browse all Laravel packages to compare alternatives.
Last updated
[!TIP] 這是英文版的README,若需要中文版前往此處查閱。
Api Response Builder (i.e. this project) is a Laravel library to help developers make JSON API responses easily, normalized, customized.
ApiResponseBuilder is inspired by the marcin-orlowski/laravel-api-response-builder with adjustments made to its features.
To install package, run with composer:
composer require juanyaolin/laravel-api-response-builder
After installing, ApiResponse facade is ready for building response.
use Juanyaolin\ApiResponseBuilder\Facades\ApiResponse;
...
// Success response
return ApiResponse::success();
// Error response
return ApiResponse::error();
And you will get following response.
// success
{
"success": true,
"code": 0,
"message": "Success",
"data": null,
}
// error
{
"success": false,
"code": -1,
"message": "Error",
"data": null
}
More detailed information can be found in documents.