1. Go to this page and download the library: Download asminog/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/ */
asminog / yii2-sentry example snippets
return [
'components' => [
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'asminog\yii2sentry\SentryTarget',
'levels' => ['error', 'warning'],
'dsn' => 'https://[email protected]/1',
// release option for project, default: null. Use "auto" to get it from git exec('git log --pretty="%H" -n1 HEAD')
'release' => '[email protected]',
// Options for sentry client
'options' => [],
// Collect additional context from $_GLOBALS, default: ['_SESSION', 'argv']. To switch off set false.
/* @see https://docs.sentry.io/enriching-error-data/context/?platform=php#extra-context
'collectContext' => ['_SERVER', '_COOKIE', '_SESSION', 'argv'],
// user attributes to collect, default: ['id', 'username', 'email']. To switch off set false.
/* @see https://docs.sentry.io/enriching-error-data/context/?platform=php#capturing-the-user */
'collectUserAttributes' => ['userId', 'userName', 'email'],
// add something to extra using extraCallback, default: null
'extraCallback' => function ($message, $extra) {
$extra['YII_ENV'] = YII_ENV;
return $extra;
}
],
],
],
],
];