bermudaphp / error-handler
v2.0.1
2023-03-11 20:32 UTC
Requires
- php: ^8.1
- bermudaphp/config: ^1.3
- bermudaphp/eventor: ^1.2
- bermudaphp/http-contracts: ^1.1
- bermudaphp/http-emitter: ^1.0
- filp/whoops: ^2.15.1
- psr/http-factory: ^1.0.1
- psr/log: ^1.1.3 || ^2.0 || ^3.0
This package is auto-updated.
Last update: 2024-11-12 00:20:22 UTC
README
composer require bermudaphp/error-handler
Usage
$generator = new ErrorResponseGenerator($psr17ResponseFactory, new WhoopsErrorGenerator($psr17ResponseFactory)); $generator->addGenerator($myConcreteErrorResponseGenerator); $errorHandler = new ErrorHandlerMiddleware(new ErrorHandler($generator)); $pipeline->pipe($errorHandler); // Add ErrorHandlerMiddleware at the beginning of the middleware queue
Event listening
$errorListenerInterfaceInstance = new LogErrorListener($logger); $errorHandler->on($errorListenerInterfaceInstance);
ServerErrorEvent
$request = $event->serverRequest; $exception = $event->throwable;