controlabs/http-exceptions

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP HTTP Status Code Exceptions

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

This package is auto-updated.

Last update: 2024-11-07 07:44:34 UTC


README

PHP HTTP Exceptions

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

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

Installation

composer require controlabs/http-exceptions

Usage

use Controlabs\Http\Exception\BadRequest;

Throws an Bad Request exception:

throw new BadRequest();

Throws an exception with a custom message:

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

Response (it can return in JSON or ARRAY format):

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

License

This software is open source, licensed under the The MIT License (MIT). See LICENSE for details.