PSR 7 error handling middleware
Install using composer
$ composer require jowy/error-handling-middleware
This library has following dependencies:
zendframework/zend-diactoros
, used for PSR 7 implementationzendframework/zend-stratigility
, provide abstraction for PSR 7 middlewareflip/whoops
, used for error formattingpsr/log
, provide abstration for logging
This library has conflict with following library:
symfony/http-kernel
, because this library has already usedSymfony\Component\HttpKernel\Exception
, despite require wholesymfony/http-kernel
package it only require the exception class
Usage on zendframework/zend-stratigility
use Zend\Stratigility\MiddlewarePipe;
use Jowy\ExceptionHandler\ExceptionHandler;
$app = new MiddlewarePipe();
$route_middleware = new ExceptionHandler($whoops_output_handler, $psr3_logger, $catch);
$app->pipe($route_middleware);
Usage on relay\relay
use Pimple\Container;
use Relay\Relay;
use Jowy\ExceptionHandler\ExceptionHandler;
$container = new Container();
$container["middleware"] = [
ExceptionHandler::class => function() {
return new ExceptionHandler($whoops_output_handler, $psr3_logger, $catch);
}
];
$resolver = function ($class) use ($container) {
return $container[$class];
}
new Relay(array_keys($container["middleware"], $resolver);
use Psr\Log\LoggerInterface;
use Whoops\Handler\HandlerInterface;
class ExceptionHandler
{
public function __construct(HandlerInterface $error_handler, LoggerInterface $logger, $catch = true);
}
MIT, see LICENSE.