PHP code example of xinningsu / yii2-honeybadger

1. Go to this page and download the library: Download xinningsu/yii2-honeybadger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xinningsu / yii2-honeybadger example snippets


[
    // ...
    'components' => [
        // ...
        // Honeybadger component
        'honeybadger' => [
            'class'  => \Sulao\YiiHoneybadger\Component::class,
            'config' => [
                'api_key'     => 'your_honeybadger_api_key', // Update with your Honeybadger API key
                'report_data' => true,
                // ...
                // For more configuration options, please refer to 
                // https://github.com/xinningsu/yii2-honeybadger/blob/master/config/honeybadger.php
                // https://docs.honeybadger.io/lib/php/reference/configuration/#default-configuration
            ],
        ],
        'log' => [
            // ...
            // Honeybadger log target
            'targets' => [
                // ...
                [
                    'class'  => \Sulao\YiiHoneybadger\Target::class,
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        // ...
    ],
    // ...
],

\Yii::error('test error');

throw new \Exception('test exception');

\Yii::$app->honeybadger->notify(new \Exception('test exception'));
\Yii::$app->honeybadger->customNotification([
    'title'   => 'Special Error',
    'message' => 'Special Error: a special error has occurred',
]);