smallruraldog / laravel-custom
该包最新版本(2.0)没有可用的许可证信息。
2.0
2019-01-24 08:39 UTC
This package is auto-updated.
Last update: 2024-09-24 21:46:20 UTC
README
laravel 5.5+ 一些自定义的扩展帮助工具
安装
首先确保已经安装了laravel
composer require smallruraldog/laravel-custom
然后运行以下命令来发布资源:
php artisan vendor:publish --provider="SmallRuralDog\LaravelCustom\LaravelCustomServiceProvider"
生成配置文件:安装完成后,所有配置都在config/laravel-custom.php
文件中。
功能列表
- API自定义返回工具
- API 资源扩展
API返回工具使用
App\Exceptions\Handler
的render
方法
public function render($request, Exception $exception) { $report = LaravelCustom::ExceptionReport($exception); if ($report) { return $report; } return parent::render($request, $exception); }
异常拦截自定义
//[message:自定义消息,code:状态码,status:状态] 'do-report' => [ \Illuminate\Auth\AuthenticationException::class => ['用户未授权', 401, 'error'] ]