afterbug/afterbug-yii

AfterBug Notifier for Yii 2 Applications.

1.0.2 2018-05-12 04:10 UTC

This package is not auto-updated.

Last update: 2024-04-26 06:06:13 UTC


README

StyleCI Total Downloads Latest Stable Version Latest Unstable Version License

This library detects errors and exceptions in your Yii Framework application and reports them to AfterBug for alerts and reporting.

Features

  • Automatically report exceptions and errors
  • Send customized diagnostic data
  • Attach user information to determine how many people are affected by the error.

Installation

The preferred way to install this extension is through composer.

Either run

composer require afterbug/afterbug-yii "~1.0"

or Add afterbug/afterbug-yii to your composer.json

"afterbug/afterbug-yii": "~1.0"

Usage

Once the extension is installed, simply modify your application configuration as follows:

$config = [
    // ...
    'components' => [
        'afterbug' => [
            'class' => 'AfterBug\AfterBugYii\AfterBug',
            'apiKey' => 'YOUR_AFTERBUG_API_KEY',
        ],
        // ...
        'errorHandler' => [
            'class' => 'AfterBug\AfterBugYii\Exceptions\ErrorHandler',
            'errorAction' => 'site/error',
        ],
    ]
];

Exclude exceptions

$config = [
    // ...
    'components' => [
        'afterbug' => [
            'class' => 'AfterBug\AfterBugYii\AfterBug',
            'apiKey' => 'YOUR_AFTERBUG_API_KEY',
            'excludeExceptions' => ['yii\web\NotFoundHttpException']
        ],
    ]
];

Callbacks

Set a callback to customize the data.

$config = [
    // ...
    'components' => [
        'afterbug' => [
            'class' => 'AfterBug\AfterBugYii\AfterBug',
            'apiKey' => 'YOUR_AFTERBUG_API_KEY',
            'on beforeNotify' => function ($event) {
                $event->client->setMetaData([
                    'custom' => 'Your custom data',
                ]);
            }
        ],
    ]
];