PHP code example of nadar / yii2-sentry
1. Go to this page and download the library: Download nadar/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/ */
nadar / yii2-sentry example snippets
return [
'components' => [
'sentry' => [
'class' => 'Nadar\Sentry\Sentry',
'dsn' => 'YOUR_SENTRY_DSN',
],
],
];
return [
'controllerMap' => [
'sentry-test' => [
'class' => 'Nadar\Sentry\SentryTestCommand',
],
],
];
return [
'components' => [
'log' => [
'targets' => [
[
'class' => 'Nadar\Sentry\SentryTarget',
'levels' => ['error', 'warning'],
'except' => [
'yii\web\HttpException:404',
'yii\web\HttpException:403',
],
'logVars' => ['_GET', '_POST', '_SESSION', '_SERVER'],
],
],
],
],
];
try {
// Your code
} catch (\Exception $e) {
Yii::$app->sentry->captureException($e);
}
Yii::$app->sentry->captureMessage('Something went wrong', 'error');
Yii::error('An error occurred');
Yii::warning('A warning message');
return [
'components' => [
'sentry' => [
'class' => 'Nadar\Sentry\Sentry',
'dsn' => 'YOUR_SENTRY_DSN',
'extraCallback' => function () {
return [
'server_id' => gethostname(),
'app_version' => '1.0.0',
];
},
],
],
];
bash
php yii sentry-test
bash
php yii sentry-test