afterbug-laravel maintained by afterbug
Description
AfterBug error monitoring for Laravel applications.
Author
Last update
2018/05/15 06:31
(dev-master)
License
Downloads
23
AfterBug for Laravel
This library detects errors and exceptions in your Laravel 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-laravel "~1.0"
or Add afterbug/afterbug-laravel to your composer.json
"afterbug/afterbug-laravel": "~1.0"
Usage
If you're on Laravel 5.4 or earlier, you need to register the ServiceProvider in config/app.php
'providers' => [
// ...
AfterBug\AfterBugLaravel\AfterBugServiceProvider::class,
],
Publish the default configuration
php artisan vendor:publish --provider='AfterBug\AfterBugLaravel\AfterBugServiceProvider'
Add AfterBug reporting to app/Exceptions/Handler.php:
public function report(Exception $e)
{
if ($this->shouldReport($e)) {
AfterBug::catchException($e);
}
return parent::report($e);
}
Callbacks
Set a callback to customize the data.
AfterBug::registerCallback(function ($config) {
$config->setMetaData([
'custom' => 'Your custom data',
]);
})->catchException($e);
Sentinel
If you are using sentinel instead of laravel Auth, you have to setup user callback manually.
AfterBug::registerCallback(function ($config) {
if (Sentinel::check()) {
$config->setUser(
Sentinel::getUser()->toArray()
);
}
})->catchException($e);
Add your AfterBug Api Key to .env:
AFTERBUG_API_KEY=Your_API_Key