phapi/middleware-mistake

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

Error and exception handling middleware for the Phapi Framework.

1.1.2 2016-08-30 09:31 UTC

This package is not auto-updated.

Last update: 2021-02-05 22:46:40 UTC


README

Build status Code Climate Test Coverage

The Mistake Middleware handles errors and exceptions by registering custom shutdown function, error handler and exception handler. When an error or exception is caught the middleware creates a log entry and prepares an error message that will be sent to the client before interacting with the pipeline by reseting the queue and telling the pipeline to only call middleware registered before the Mistake Middleware (usually only serializers and middleware responsible for sending the response to the client).

Installation

This middleware is by default included in the Phapi Framework but if you need to install it it's available to install via Packagist and Composer.

$ php composer.phar require phapi/middleware-mistake:1.*

Configuration

There are two configuration options available for the Mistake Middleware; if error messages should be shown. This is handy to have enabled during development since it gives a more detailed error message. It should however be turned off in production since an error message will be serialized and return to the client. (Default: off).

The second option gives the opportunity to disable logging for specific status codes. This comes in handy if you, for example, don't want to flood your logs with 404 NotFound exceptions.

<?php

// For development
$pipeline->pipe(new \Phapi\Middleware\Mistake\Mistake($displayErrors = false, $doNotLog = [ 404 ]));

See the configuration documentation for more information about how to configure the integration with the Phapi Framework.

Phapi

This middleware is a Phapi package used by the Phapi Framework. The middleware are also PSR-7 compliant and implements the Phapi Middleware Contract.

License

The Mistake Middleware is licensed under the MIT License - see the license.md file for details

Contribute

Contribution, bug fixes etc are always welcome.