bliptrace/yii2 adds an application component plus a bootstrap hook that forwards exceptions surfaced by the Yii error handler. PHP 8.2+, Yii 2.0.
Install from GitHub. This package is not on Packagist yet. Source: github.com/bliptrace/bliptrace-yii2.
Install
composer config repositories.bliptrace-yii2 vcs https://github.com/bliptrace/bliptrace-yii2
composer require bliptrace/yii2:dev-main
Configure
// config/web.php
use G8Scope\Php\Env; // reads BLIPTRACE_<NAME>
return [
'bootstrap' => ['g8scope'],
'components' => [
'g8scope' => [
'class' => \G8Scope\Yii2\G8ScopeComponent::class,
'enabled' => filter_var(Env::get('ENABLED', 'true'), FILTER_VALIDATE_BOOL),
'key' => Env::get('KEY'),
'endpoint' => Env::get('ENDPOINT', 'https://ingest.bliptrace.com'),
'environment' => YII_ENV,
'release' => Env::get('RELEASE'),
'timeout' => 3,
'ignoreExceptions' => [\yii\web\NotFoundHttpException::class],
'scrubKeys' => ['password', 'token', 'secret'],
],
],
];
Listing the component in bootstrap initialises it on every request. After each request it checks whether the Yii error handler caught an exception and reports it with the request context.
Report a handled exception
try {
// ...
} catch (\Throwable $e) {
Yii::$app->g8scope->report($e);
}
Each report carries the request method, absolute URL and headers (without authorization and cookie), plus the signed-in user’s id.