0.3.0 2016-12-29 11:39 UTC

This package is not auto-updated.

Last update: 2024-04-13 22:45:21 UTC


An exception library that can be used to bubble up specific http errors through middleware.

Build Status Code Climate Test Coverage


It's recommended that you use Composer to install peel.

$ composer require avalanche-development/peel

peel requires PHP 5.6 or newer.


function someMiddleware($request, $response, $next) {
    $body = (string) $request->getBody();
    $body = json_decode($value);
    if (json_last_error() !== JSON_ERROR_NONE) {
        throw new AvalancheDevelopment\Peel\HttpError\BadRequest('Invalid JSON');
    // etc

Each exception implements AvalancheDevelopment\Peel\HttpErrorInterface, which enforces two methods, getStatusCode and getStatusMessage. These give you the expected HTTP code and message for any sort of error handler.


Note: see avalanche-development/crash-pad for an error handler that takes advantage of these standardized exceptions.


This library is a work in progress - there may be additional options (like, error metadata) added for different statuses as needed.


To execute the test suite, you'll need phpunit (and to install package with dev dependencies).

$ phpunit


peel is licensed under the MIT license. See License File for more information.