PHP code example of jowy / exception-handling-middleware

1. Go to this page and download the library: Download jowy/exception-handling-middleware library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jowy / exception-handling-middleware example snippets


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);

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);
}