afterbug/afterbug

AfterBug error monitoring for PHP applications.

1.0.2 2018-05-24 03:48 UTC

README

StyleCI Total Downloads Latest Stable Version Latest Unstable Version License

This library detects errors and exceptions in your PHP 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 "~1.0"

Add afterbug/afterbug to your composer.json

"afterbug/afterbug": "~1.0"

Usage

$afterbug = AfterBug\Client::make('AFTERBUG_API_KEY')

// Register AfterBug error handler
AfterBug\Exceptions\ErrorHandler::register($afterbug);

// will be reported by the exception handler
throw new \Exception('testing exception handler');

Exclude exceptions

Sets for which exception classes we should not send to AfterBug.

$afterbug->registerCallback(function ($config) {
    $config->setExcludeExceptions(['Namespace\ExceptionClass']);
});

Callbacks

Set a callback to customize the data.

$afterbug->registerCallback(function ($config) {
    $config->setEnvironment('Production')
        ->setUser([
            'id' => 1,
            'name' => 'Alfa'
        ])
        ->setMetaData([
            'custom' => 'Your custom data'
        ]);
});

Integration with frameworks

Other packages exists to integrate this SDK into the most common frameworks.

Official Integrations

The following integrations are supported by AfterBug team.