The preferred method of installation is via Composer. Run the following command to install the latest version of a package and add it to your project's composer.json
:
composer require wecodein/error-handling
use WeCodeIn\ErrorHandling\Handler\ExceptionHandler;
use WeCodeIn\ErrorHandling\Handler\FatalErrorHandler;
use WeCodeIn\ErrorHandling\Handler\ThrowableErrorHandler;
use WeCodeIn\ErrorHandling\Processor\CallableProcessor;
require __DIR__ . '/../vendor/autoload.php';
ini_set('log_errors', 0);
ini_set('display_errors', 0);
error_reporting(E_ALL);
$processor = new CallableProcessor(function (Throwable $throwable) : Throwable {
// log, emmit...
return $throwable;
});
$errorHandler = new ThrowableErrorHandler();
$errorHandler->register();
$exceptionHandler = new ExceptionHandler($processor);
$exceptionHandler->register();
$fatalErrorHandler = new FatalErrorHandler(20, $processor);
$fatalErrorHandler->register();
trigger_error('Error');
Released under MIT License - see the License File for details.