PHP code example of otsec / yii2-sentry

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

    

otsec / yii2-sentry example snippets


return [
    'components' => [
    	...
    
        'sentry' => [
            'class' => 'otsec\yii2\sentry\Raven',
            'dsn' => 'https://****@sentry.io/12345',
        ],
    ],
];

return [
    'bootstrap' => ['sentry'],
    
    ...
];

'components' => [
	...
	
    'sentry' => [
	    ...
	    
	    // Register Raven_Client error and exception handler on init.
	    // Enabled by default
        'enableErrorHandler' => true,

        // Options will be passed to Raven_Client
        'options' => [],
        
        // Cathing JS errors is disabled by default.
        'enableClientScript' => false,
        
        // Options for client library.
        'clientOptions' => [],
        
        // DSN for client libary. 
        // Will be extracted from private DSN if empty.
        'publicDsn' => null,
        
        // Client library will be loaded from CDN by default.
        // You can use any other asset bundle if you want. 
        'assetBundle' => 'otsec\yii2\sentry\RavenCdnAsset',
        
        // Asset bundles for Bower and NPM already created but you have to 
        // install assets before you will use it.
        // 'assetBundle' => 'otsec\yii2\sentry\RavenBowerAsset',
        // 'assetBundle' => 'otsec\yii2\sentry\RavenNpmAsset',
    ],
],

try {
	throw new Exception('Oh, shit!');
} catch (Exception $e) {
	Yii::$app->sentry->captureException($e, ['extra' => 'data']);
}

Yii::$app->sentry->extraContext($data);
Yii::$app->sentry->tagsContext($data);
Yii::$app->sentry->userContext($data);
Yii::$app->sentry->clearContext();

$ravenClient = Yii::$app->sentry->getClient();