Download the PHP package wubinworks/error-handler without Composer
On this page you can find all versions of the php package wubinworks/error-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wubinworks/error-handler
More information about wubinworks/error-handler
Files in wubinworks/error-handler
Package error-handler
Short Description Error Handler converts PHP's traditional runtime errors into ErrorException and respects user specified error reporting level. Exception Handler can output and/or log exception message with well-formatted stack trace.
License OSL-3.0
Homepage https://www.wubinworks.com
Informations about the package error-handler
PHP Error Handler and Exception Handler
This package contains \Wubinworks\ErrorHandler\ErrorHandler and \Wubinworks\ErrorHandler\ExceptionHandler.
The \Wubinworks\ErrorHandler\ErrorHandler::handle converts PHP's traditional runtime errors into \ErrorException and respects user specified error reporting level.
\Wubinworks\ErrorHandler\ErrorHandler::handle can be used as a callback for set_error_handler directly.
The \Wubinworks\ErrorHandler\ExceptionHandler::handle handles any \Throwable and controls whether to output exception message and logging. You can also get the exception message with well-formatted stack trace information as string.
\Wubinworks\ErrorHandler\ExceptionHandler::handle can be used as a callback for set_exception_handler directly.
Requirements
- PHP >= 5.3
Installation
Usage
ErrorHandler
Just set_error_handler([new \Wubinworks\ErrorHandler\ErrorHandler(), 'handle']).
This handler respects the error_reporting level set by user and if the traditional runtime error needs to be reported, an \ErrorException will be thrown. The \ErrorException's severity level is set to the handled error level.
Example:
ExceptionHandler
\Wubinworks\ErrorHandler\ExceptionHandler::__construct has 3 parameters and these parameters control the handler's behavior.
-
canOutputControls whether the handler can output to console/browser. -
loggerMust be typenull|\Psr\Log\LoggerInterface. Set tonullto disable logging. Note the log level is fixed toERROR. isTraceIgnoreArgsControls whether to include function/method parameter information in the output/log.
Example:
You can also do like this:
The output/log include exception message, exception class and well-formatted stack trace information.
Example output/log:
Unit testing
Install the require-dev dependencies and run the following command.
♥
If you like this package or this package helped you, please share and give a ★☆star☆★, it's NOT hard!