controlabs/http-exceptions

PHP HTTP 状态码异常

v1.1 2018-11-06 18:14 UTC

This package is auto-updated.

Last update: 2024-09-07 07:22:49 UTC


README

PHP HTTP 异常

Build Status Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status PHPStan

License Latest Stable Version Latest Unstable Version composer.lock Total Downloads

安装

composer require controlabs/http-exceptions

用法

use Controlabs\Http\Exception\BadRequest;

抛出错误的请求异常

throw new BadRequest();

抛出带自定义信息的异常

throw new BadRequest("I'm gonna make him an offer he can't refuse.");

响应(可以返回 JSON 或 ARRAY 格式)

try {
} catch (BadRequest $e) {
    $e->response()->toArray();
    // or
    $e->response()->toJson();
}

许可证

本软件是开源的,采用 The MIT License (MIT) 许可。详细信息请参阅 LICENSE