2017 © Pedro Peláez
 

extension yii2-web-errorhandler

Yii2 customizable error handler

image

cronfy/yii2-web-errorhandler

Yii2 customizable error handler

  • Thursday, October 6, 2016
  • by cronfy
  • Repository
  • 1 Watchers
  • 3 Stars
  • 1,546 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 12 % Grown

The README.md

Yii2 customizable ErrorHandler

Can be customized in terms of which error types should be converted to exceptions or only logged., (*1)

Installation

php composer.phar require cronfy/yii2-web-errorhandler

Usage

Replace errorHandler component in application configuration and configure error types you want to convert to exceptions or log. Default is E_ALL | E_STRICT., (*2)

Example:, (*3)

...
    'components' => [
        'errorHandler' => [
            'class' => 'cronfy\yii\web\ErrorHandler',
            'typesToExceptions' => YII_DEBUG ? (E_ALL | E_STRICT) : false,
            'typesToLog' => E_ALL | E_STRICT,
        ],
    ],
...

This configuration will convert all php notices and warnings to exceptions only in debug mode, and none in production environment. Errors will be logged both in debug and production modes. You can customize error types that go to log or convereted to exceptions., (*4)

Errors are logged via internal Yii2 log component., (*5)

You can enable/disable ErrorHandler for particular error types by setting typesToHandle option. All error types not specified there will be forwarded to internal php error handler:, (*6)

...
    'components' => [
        'errorHandler' => [
            'class' => 'cronfy\yii\web\ErrorHandler',
            'typesToHandle' => E_ALL & ~E_NOTICE,

            // NOTE: although E_ALL is set here, PHP Notices will not be converted to exceptions, 
            // because they were disabled via 'typesToHandle' option above.
            // PHP Warnings and other errors will be converted to exceptions.
            'typesToExceptions' => E_ALL,
        ],
    ],
...

The Versions

06/10 2016

dev-master

9999999-dev

Yii2 customizable error handler

  Sources   Download

GPL-3.0

The Requires

 

06/10 2016

v0.0.1

0.0.1.0

Yii2 customizable error handler

  Sources   Download

GPL-3.0

The Requires