lucidtaz/yii2-whoops

Yii2 bindings for Whoops error handler

dev-master 2019-02-06 14:57 UTC

This package is auto-updated.

Last update: 2024-11-07 05:41:44 UTC


README

This library provides easy integration of filp/whoops into Yii2. Whoops is a pretty exception and error formatter. This library enables you to use it by configuring an ErrorHandler in your application config.

USAGE

Configure web.php to disable Yii's built-in error handler and use the new one:

<?php
$config = [
    // ...
    'components' => [
        'errorHandler' => [
            'class' => 'lucidtaz\yii2whoops\ErrorHandler',

            // NOTE: yii2-app-basic comes with this errorAction line by default,
            // be sure to comment/remove it, or you will get an
            // UnknownAttributeException when running your code:
            // 'errorAction' => 'site/error'
        ],
        // ...
    ],
    // ...
];

Or to only use it in Dev+Debug mode, to prevent your source code displaying in production:

<?php
$config = [
    // ...
    'components' => [
        'errorHandler' => YII_ENV_DEV && YII_DEBUG ? [
            'class' => 'lucidtaz\yii2whoops\ErrorHandler',
        ] : [
            'class' => 'yii\web\ErrorHandler',
            'errorAction' => 'site/error'
        ],
        // ...
    ],
    // ...
];