askync / utils
laravel/lumen 框架的实用工具
1.11.1
2022-08-01 05:13 UTC
README
#Askync/Utils
###为 laravel/lumen 框架的一些 API 实用工具
成功响应
return \Askync\Utils\Facades\AskyncResponse::success([ 'name' => 'John Doe', 'email' => 'doe@john.com' ]);
错误响应
return \Askync\Utils\Facades\AskyncResponse::success(401, 'Unauthorized');
将错误作为响应抛出,中断进程并在代码的任何位置返回响应
throw new \Askync\Utils\Utils\ResponseException('Server cannot accept the data type');
##设置
bootstrap/app.php
... $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, \Askync\Utils\Handler\LumenErrorHandler::class ); ... $app->register(\Askync\Utils\UtilsServiceProvider::class); ...