Downloads
Stars
Version
[!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.