coreuxio/lib
最新稳定版本:v1.0.8
Composer 安装命令:
composer require coreuxio/lib
包简介
A small set of tools to speed up Laravel API development
关键字:
README 文档
README
A personal set of tools to start building APIs or Laravel Apps
Features
- Standard API Response
- Request Time
Standard API Response
Adding meta data helps when debugging from Webhook logs
{
"status": "success",
"data": "This could be anything including arrays and object",
"errors": [],
"meta": {
"httpCode": 200,
"milliseconds": 120,
"timestamp": "2023-04-07 17:19:05"
},
"pagination": null
}
Usage
In your App/Http/Controller add ApiResponse as a trait
use \Coreux\Lib\API\Traits\ApiResponse; class Controller extends BaseController { use AuthorizesRequests, ValidatesRequests, ApiResponse; }
Now you can respond return this as a successful return
return $this->apiReturn($users);
You can also use Pagination from Eloquent
return $this->apiReturnPaginated($usersPaginated,$transformer=null);
Or you can return an error and specify the code
return $this->apiError($errors,$code=400);
Request Time
By defining at the following line in your index.php (App entry) the API response will be able to return the milliseconds your code ran for
define('APP_START', microtime(true));
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-04-22