xinningsu / yii2-honeybadger
Honeybadger logger for Yii2, Honeybadger integration for Yii2.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/xinningsu/yii2-honeybadger
Requires
- php: ^8.0.0
- honeybadger-io/honeybadger-php: ^2.0.0
- yiisoft/yii2: ^2.0.0
Requires (Dev)
- phpunit/phpunit: >=5.0
- squizlabs/php_codesniffer: ^3.0
This package is not auto-updated.
Last update: 2025-11-28 13:57:07 UTC
README
Honeybadger integration for Yii2, Honeybadger Error Logger.
Installation
composer require xinningsu/yii2-honeybadger
Usage
Once you have finished the Honeybadger installation, set up Honeybadger component and Honeybadger log target in Yii common config file, e.g., config/web.php:
[
// ...
'components' => [
// ...
// Honeybadger component
'honeybadger' => [
'class' => \Sulao\YiiHoneybadger\Component::class,
'config' => [
'api_key' => 'your_honeybadger_api_key', // Update with your Honeybadger API key
'report_data' => true,
// ...
// For more configuration options, please refer to
// https://github.com/xinningsu/yii2-honeybadger/blob/master/config/honeybadger.php
// https://docs.honeybadger.io/lib/php/reference/configuration/#default-configuration
],
],
'log' => [
// ...
// Honeybadger log target
'targets' => [
// ...
[
'class' => \Sulao\YiiHoneybadger\Target::class,
'levels' => ['error', 'warning'],
],
],
],
// ...
],
// ...
],
Testing
In the controller file, add the code below
\Yii::error('test error');
Or trigger an exception In the controller
throw new \Exception('test exception');
To manually send reports, you can refer to the code below:
\Yii::$app->honeybadger->notify(new \Exception('test exception')); \Yii::$app->honeybadger->customNotification([ 'title' => 'Special Error', 'message' => 'Special Error: a special error has occurred', ]);
Then, check if the report is available in the Honeybadger.