phapi / middleware-mistake
Error and exception handling middleware for the Phapi Framework.
Installs: 1 552
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: >=5.6.0
- phapi/contract: 1.*
- phapi/exception: 1.*
- phapi/http: 1.*
- psr/http-message: 1.*
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- mockery/mockery: 0.9.*
- phpunit/phpunit: 4.*
This package is not auto-updated.
Last update: 2021-02-05 22:46:40 UTC
README
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.