承接 anil/exception-response 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

anil/exception-response

最新稳定版本:v0.0.1

Composer 安装命令:

composer require anil/exception-response

包简介

README 文档

README

About

The purpose of this method is to handle exceptions that occur during the execution of the application.

The method first checks if the request path matches the pattern 'api/*' or if the request expects a JSON response. If either of these conditions is true, it calls the apiException method and passes in the $request and $exception parameters. This method likely handles the exception and returns a JSON response.

If the request does not match the pattern 'api/*' and does not expect a JSON response, the method calls the parent render method and passes in the $request and $exception parameters. This will likely render a standard error page.

Overall, this code appears to be part of an error handling system that differentiates between API requests and other requests and provides appropriate error responses for each.

Installation

Composer

composer require anil/exception-response

Use inside Handler.php


use Anil\ExceptionResponse\Traits\ApiExceptionResponse;
class Handler extends ExceptionHandler
{
    use ApiExceptionResponse;
    
    public function render($request, Throwable $exception)
    {
        if ($request->is('api/*') || $request->expectsJson()) {

            return $this->apiException($request, $exception);
        }

        return parent::render($request, $exception);
    }

统计信息

  • 总下载量: 4.58k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-31