wecodein/error-handling

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Robust and extensible error handling system for PHP

dev-master / 1.0.x-dev 2017-11-08 19:04 UTC

This package is not auto-updated.

Last update: 2021-09-17 13:31:38 UTC


README

Build Status Code Quality Code Coverage Latest Version PDS Skeleton

Installation

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

Usage

use WeCodeIn\ErrorHandling\Handler\ExceptionHandler;
use WeCodeIn\ErrorHandling\Handler\FatalErrorHandler;
use WeCodeIn\ErrorHandling\Handler\HandlerAggregate;
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, render...
    return $throwable;
});

$handler = new HandlerAggregate(
    new ThrowableErrorHandler(),
    new ExceptionHandler($processor),
    new FatalErrorHandler(20, $processor)
);

$handler->register();

trigger_error('Error');

Credits

License

Released under MIT License - see the License File for details.