codin / fault
Extendable error handler
Installs: 5 345
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4 || >= 8.0
Requires (Dev)
- friends-of-phpspec/phpspec-code-coverage: @stable
- friendsofphp/php-cs-fixer: @stable
- phpspec/phpspec: @stable
- phpstan/phpstan: @stable
README
Simple error exception handler
Usage
$error = new Codin\Fault\ErrorHandler(); if ('cli' === php_sapi_name()) { $error->attach(new Codin\Fault\Handler\ConsoleHandler()); } else { $error->attach(new Codin\Fault\Handler\WebHandler($debug = true)); } $error->register();
Example with monolog+sentry
$options = [ 'dsn' => '...', 'environment' => '...', ]; $builder = new Sentry\ClientBuilder(new Sentry\Options($options)); $sentry = new Sentry\State\Hub($builder->getClient()); $logger = new Logger('app'); $logger->pushHandler(new Sentry\Monolog\Handler($sentry, Logger::NOTICE)); $error = new Codin\Fault\ErrorHandler(); $error->attach(new Codin\Fault\Handler\PsrHandler($logger)); $error->register();