2017 © Pedro Peláez
 

library php-error-handler

Handling PHP errors (Notice, Warning, etc.)

image

struzik-vladislav/php-error-handler

Handling PHP errors (Notice, Warning, etc.)

  • Sunday, April 8, 2018
  • by struzik-vladislav
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

PHP Error Handler Travis

Handling PHP errors in various processors., (*1)

Types of errors that can be handled according to set_error_handler: * E_STRICT * E_RECOVERABLE_ERROR * E_NOTICE * E_WARNING * E_DEPRECATED * E_USER_ERROR * E_USER_NOTICE * E_USER_WARNING * E_USER_DEPRECATED, (*2)

Processors

ReturnFalseProcessor

The processor for enabling native PHP handler after custom., (*3)

LoggerProcessor

The processor for writing to the PSR-3 compatible logger like Monolog., (*4)

IntoExceptionProcessor

The processor for converting errors to exceptions. The basic type of throwing exception is Struzik\ErrorHandler\Exception\ErrorException., (*5)

Usage

<?php

use Struzik\ErrorHandler\ErrorHandler;
use Struzik\ErrorHandler\Processor\LoggerProcessor;
use Struzik\ErrorHandler\Processor\IntoExceptionProcessor;
use Struzik\ErrorHandler\Exception\ErrorException;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$logger = new Logger('ErrorHandler DEMO');
$logger->pushHandler(new StreamHandler('php://output', Logger::DEBUG));

$errorHandler = new ErrorHandler();
$errorHandler->pushProcessor(new IntoExceptionProcessor())
    ->pushProcessor(new LoggerProcessor($logger));

try {
    $errorHandler->set();
    trigger_error('Dummy error', E_USER_NOTICE);
    $errorHandler->restore();
} catch (ErrorException $e) {
    echo $e;
}

/*
[2017-05-13 21:42:46] ErrorHandler DEMO.NOTICE: Dummy error in /srv/php-error-handler/example.php:21 {"backtrace":"#0 /srv/php-error-handler/src/ErrorHandler.php(39): Struzik\\ErrorHandler\\Processor\\LoggerProcessor->handle(1024, 'Dummy error', '/srv/php-error-...', 21)\n#1 [internal function]: Struzik\\ErrorHandler\\ErrorHandler->handle(1024, 'Dummy error', '/srv/php-error-...', 21, Array)\n#2 /srv/php-error-handler/example.php(21): trigger_error('Dummy error', 1024)\n#3 {main}"} []

Struzik\ErrorHandler\Exception\UserNoticeException: Dummy error in /srv/php-error-handler/example.php:21
Stack trace:
#0 /srv/php-error-handler/src/ErrorHandler.php(39): Struzik\ErrorHandler\Processor\IntoExceptionProcessor->handle(1024, 'Dummy error', '/srv/php-error-...', 21)
#1 [internal function]: Struzik\ErrorHandler\ErrorHandler->handle(1024, 'Dummy error', '/srv/php-error-...', 21, Array)
#2 /srv/php-error-handler/example.php(21): trigger_error('Dummy error', 1024)
*/

The Versions

08/04 2018

dev-master

9999999-dev

Handling PHP errors (Notice, Warning, etc.)

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Vladislav Struzik

php exception converter error handler

08/04 2018

v1.0.2

1.0.2.0

Handling PHP errors (Notice, Warning, etc.)

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Vladislav Struzik

php exception converter error handler

15/05 2017

v1.0.1

1.0.1.0

Handling PHP errors (Notice, Warning, etc.)

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Vladislav Struzik

php exception converter error handler

13/05 2017

v1.0.0

1.0.0.0

Handling PHP errors (Notice, Warning, etc.)

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

by Vladislav Struzik

php exception converter error handler