1. Go to this page and download the library: Download enjoys/error-handler 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/ */
enjoys / error-handler example snippets
$exceptionHandler = new \Enjoys\ErrorHandler\ExceptionHandler\ExceptionHandler();
$errorLogger = new \Enjoys\ErrorHandler\ErrorLogger\ErrorLogger(\Psr\Log\LoggerInterface $psr3logger);
$errorHandler = new \Enjoys\ErrorHandler\ErrorHandler($exceptionHandler, $errorLogger);
$errorHandler->register();
/** @var Enjoys\ErrorHandler\ExceptionHandler\ExceptionHandler $exceptionHandler */
use Enjoys\ErrorHandler\ExceptionHandler\OutputProcessor\Html;
use Enjoys\ErrorHandler\ExceptionHandler\OutputProcessor\Json;
use Enjoys\ErrorHandler\ExceptionHandler\OutputProcessor\Xml;
use Enjoys\ErrorHandler\ExceptionHandler\View\Html\SimpleHtmlErrorViewVeryVerbose;
// Заменяет всю карту сопоставлений outputErrorViewMap
$exceptionHandler->setOutputErrorViewMap([
Html::class => SimpleHtmlErrorViewVeryVerbose::class,
Json::class => ImplementationOfErrorViewInterface::class
]);
// Добавляет или заменяет соответсвующее сопоставление в outputErrorViewMap
$exceptionHandler->setOutputErrorView(Xml::class, ImplementationOfErrorViewInterface::class);
/** @var \Enjoys\ErrorHandler\ErrorLogger\ErrorLogger $logger */
// Устанавливает дефолтный уровень лога, используется если не определено иное (по-умолчанию LogLevel::NOTICE)
$logger->setDefaultLogLevel(\Psr\Log\LogLevel::INFO);
// Переопределяет уровень лога для конкретного типа ошибок
$logger->setLogLevel([E_USER_WARNING, E_WARNING], \Psr\Log\LogLevel::NOTICE);
// Переопределяет формат сообщений в логах
$logger->setLoggerFormatMessage([E_DEPRECATED, E_USER_DEPRECATED], 'Deprecated message: %2$s in %3$s on line %4$s');
// Переопределяет названия каналов, если поддерживается, для конкретного типа ошибок
$logger->setLoggerName([E_DEPRECATED, E_USER_DEPRECATED], 'Deprecation');
// Возвращает \Psr\Log\LoggerInterface
$logger->getPsrLogger();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.