aloframework / handlers
The error and exception handlers of AloFramework
Requires
- php: >=5.5.9
- aloframework/common: ^2.0
- aloframework/config: ^2.0
- aloframework/log: ^3.0
- raveren/kint: ^1.0
- symfony/console: ^2.7 || ^3.0
- symfony/var-dumper: ^2.7 || ^3.0
README
A powerful error and exception handler of AloFramework. It can automatically log errors and exceptions if an object implementing the \Psr\Log\LoggerInterface is passed on and will echo output based on your server's error reporting settings, altering its format depending on whether an error is raised during a HTTP or CLI call.
Latest release API documentation: https://aloframework.github.io/handlers/
Installation
Installation is available via Composer:
composer require aloframework/handlers
Usage
- To enable the exception handler call
\AloFramework\Handlers\ExceptionHandler::register()
- To enable the error handler call
\AloFramework\Handlers\ErrorHandler::register()
- To enable the shutdown handler call
\AloFramework\Handlers\ShutdownHandler::register()
Logging
Every error and exception has to be logged in this package. You can supply your own logger to have more control; if you don't, aloframework/log will be used with its default settings.
Configuration
Configuration is done via the classes in the AloFramework\Handlers\Config
namespace.
Common
CFG_CSS_PATH
- path to the CSS file which will style the HTML output. Defaults to error.min.css in the src directory.CFG_TRACE_MAX_DEPTH
- maximum number of debug backtrace items to display [50]CFG_BACKGROUND
- CLI output background colour [default]CFG_FOREGROUND_NOTICE
- CLI output notice level foreground colour [cyan]CFG_FOREGROUND_WARNING
- CLI output warning level foreground colour [yellow]CFG_FOREGROUND_ERROR
- CLI output error/exception level foreground colour [red]CFG_FORCE_HTML
- Whether to force HTML output even in CLI mode [false]
Error Handlers' Config
CFG_ERROR_LEVEL
- Which error levels to handle. Defaults to the value oferror_reporting()
.CFG_LOG_ERROR_LOCATION
- Whether to include the error location in the log [true]
Exception Handlers' Config
CFG_EXCEPTION_DEPTH
- Maximum number previous exceptions to output in the exception handler [10]CFG_LOG_EXCEPTION_LOCATION
Whether to include the exception location in the log [true]