PHP code example of alex-salt / yii2-sentry

1. Go to this page and download the library: Download alex-salt/yii2-sentry 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/ */

    

alex-salt / yii2-sentry example snippets


'components' => [
    'sentry' => [
        'class' => 'alexsalt\sentry\Client',
        'dsn' => '<your_dsn_url>',
        'options' => [
            'exclude' => [
                'yii\\web\\NotFoundHttpException',
                'yii\\web\\ForbiddenHttpException',
                'yii\\web\\UnauthorizedHttpException',
                'yii\\base\\InvalidRouteException',
            ],
        ],
    ],
    'errorHandler' => [
        'class' => 'alexsalt\sentry\ConsoleErrorHandler',
    ],
    'log' => [
        'targets' => [
            [
                'class' => 'alexsalt\\sentry\\LogTarget',
                'levels' => [ 'warning', 'error' ],
            ],
        ],
    ],
]

// basic
Yii::error('message');
// extra data
Yii::error([
    'msg' => 'message name',
    'data' => [
        'foo' => 'bar',
    ],
]);
// capture exception
try {
    throw new \Exception('test');
} catch (\Exception $e) {
    Yii::$app->errorHandler->logException($e);
}