PHP code example of demi / yii1-bugsnag

1. Go to this page and download the library: Download demi/yii1-bugsnag 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/ */

    

demi / yii1-bugsnag example snippets




return [
    'components' => [
        'bugsnag' => [
            'class' => '\demi\bugsnag\yii1\BugsnagComponent',
            'bugsnagApiKey' => '<YOU API KEY>',
            'notifyReleaseStages' => ['production', 'development'],
            'projectRoot' => realpath(__DIR__ . '/../..'),
        ],
        'log' => [
            'class' => 'CLogRouter',
            'routes' => [
                [
                    'class' => '\demi\bugsnag\yii1\BugsnagLogRoute',
                    'levels' => 'error, warning',
                ],
            ],
        ],
    ],
];



$mainConfig = ents' => [
        'errorHandler' => [
            'class' => '\demi\bugsnag\yii1\BugsnagErrorHandler',
        ],
        'bugsnag' => $mainConfig['components']['bugsnag'],
        'log' => [
            'class' => 'CLogRouter',
            'routes' => [
                [
                    'class' => '\demi\bugsnag\yii1\BugsnagLogRoute',
                    'levels' => 'error, warning',
                ],
            ],
        ]
    ],
];



// log exception
Yii::app()->bugsnag->notifyException(\Exception $e);
// log message
Yii::app()->bugsnag->notifyError('TestErrorName', 'Example warning message!', ['foo' => 'bar'], 'warning');

// or native exception
throw \Exception('Example exception message');
// or native log message
Yii::log('Example warning message!', 'warning', 'application.error');