dmftaras / yii2-sentry
Yii 2 extension for Sentry
Installs: 269
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Type:yii2-extension
Requires
- php: >=7.4.0
- guzzlehttp/guzzle: ^7.0
- guzzlehttp/psr7: ^1.0
- php-http/guzzle7-adapter: *
- sentry/sentry: >=2.1.0
- yiisoft/yii2: *
This package is not auto-updated.
Last update: 2025-01-24 03:33:07 UTC
README
Sentry provides real-time crash reporting for web apps, both server and client side. This is a Yii 2 extension which lets you integrate your projects to Sentry and log PHP and JavaScript errors.
Brought to you by dmftaras.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist dmftaras/yii2-sentry "~1.0.0"
or add the following line to the require section of your composer.json
file:
"dmftaras/yii2-sentry": "~1.0.0"
Requirements
Yii 2 and above. Sentry 9 and above.
You can use this extension with both the hosted and on-premise version of Sentry.
Usage
Once the extension is installed, set your configuration in common config file:
'components' => [ 'sentry' => [ 'class' => 'dmftaras\sentry\Component', 'dsn' => 'YOUR-PRIVATE-DSN', // private DSN 'environment' => 'staging', // if not set, the default is `production` 'release' => '1.0' // release version ], 'log' => [ 'targets' => [ [ 'class' => 'dmftaras\sentry\Target', 'levels' => ['error', 'warning'], 'except' => [ 'yii\web\HttpException:404', ], ], ], ], ],
To skip collecting errors in the development environment, disable the component with this parameter:
'components' => [ 'sentry' => [ 'enabled' => false, ], ],
To collect error manually
try { throw new \Exception('fatal error'); } catch (\Exception $e) { \Yii::$app->sentry->captureException($e); }
To collect custom message
\Yii::$app->sentry->captureMessage('test msg');
License
Code released under MIT License.