idealogica / error-handler
Error handler based on Booboo with HTML and JSON support
1.0.18
2021-11-11 09:36 UTC
Requires
- php: >=7.1.0
- ext-json: *
- idealogica/good-view: ~1.0
- idealogica/log-x: ~1.1.2
- league/booboo: ~2.0
- psr/http-message: ~1.0
Requires (Dev)
- guzzlehttp/psr7: ~1.5
- idealogica/debug: ~1.1
README
1. Features
- allows to setup formatters based on the request uri
- automatically detects cli mode and uses appropriate formatter
- uses templates for customizable error pages
- can detect exceptions which are not allowed to be shown and show general "server error" message instead of exact exception information
2. Installation
composer require idealogica/error-handler:~1.0.0
3. Basic example
$handler = new ErrorHandler(
new ServerRequest('GET', new Uri('https://www.server.test/api/endpoint')),
[
'/api/.*' => [new JsonFormatter()],
'.*' => [new HtmlFormatter(ViewFactory::createStringViewFactory())]
],
[
new CommandLineFormatter()
],
$debugMode,
InvalidArgumentException::class
);
$handler->register();
4. License
ErrorHandler is licensed under a MIT License.