middlewares/whoops
Middleware to use Whoops as error handler.
Requirements
- PHP >= 7.0
- A PSR-7 http library
- A PSR-15 middleware dispatcher
Installation
This package is installable and autoloadable via Composer as middlewares/whoops.
composer require middlewares/whoops
Example
$dispatcher = new Dispatcher([
new Middlewares\Whoops()
]);
$response = $dispatcher->dispatch(new ServerRequest());
Options
__construct(Whoops\Run $whoops = null, Whoops\Util\SystemFacade $system = null)
Allows to provide a custom Whoops\Run
instance. If it's not defined, creates an instance automatically. You can provide also the SystemFacade
used by the Run
instance, in order to implement a special behaviour with fatal errors.
catchErrors(true)
To catch not only throwable exceptions, but also php errors. This makes whoops to be registered temporary in order to capture the errors using set_error_handler
. It's enabled by default so, to disable it you have to use ->catchErrors(false)
;
handlerContainer(Psr\Container\ContainerInterface $container)
To define a custom PSR-11 container used to create the intance of Whoops\Handler\HandlerInterface
based in the Accept
header in the request.
responseFactory(Psr\Http\Message\ResponseFactoryInterface $responseFactory)
A PSR-17 factory to create the error response.
Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.