- 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
composer require idealogica/error-handler:~1.0.0
$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();
ErrorHandler is licensed under a MIT License.