mojtabarks/api-exceptions

api中使用的异常列表,帮助你轻松管理api异常

v2.1.1 2021-11-15 22:15 UTC

This package is auto-updated.

Last update: 2024-09-16 04:31:39 UTC


README

用于在laravel或lumen中创建和传递响应的轻量级包

安装

$ composer require mojtabarks/api-exceptions

lumen特定安装

如果你的项目是lumen,你应该将mojtabarks/api-exceptions/src/config/exceptions复制到你的config目录!注意:如果你没有config目录,请创建它!

然后在你的bootstrap/app.php文件中添加以下代码

  $app->configure(exceptions);

laravel特定安装

$ php artisan vendor:publish --provider="Mojtabarks/ApiExceptions/Providers/ApiExceptionServiceProvider"

用法

像这样覆盖App\Exceptions\Handlerrender方法

    use Mojtabarks\ApiExceptions\Handlers\ApiException;
  
    public function render($request, Throwable $exception)
    {
        return ApiException::handle($exception);
    }

作者

  • Mojtaba Rakhisi - 初始工作 - github

许可

本项目采用MIT许可证 - 请参阅LICENSE.md文件以获取详细信息