JuKu / JuKuCMS

Open Source CMS should be the fastest CMS world wide (WIP).
Other
5 stars 1 forks source link

Setup Airbrake for your PHP application #127

Open JuKu opened 6 years ago

JuKu commented 6 years ago

Installation

Install Airbrake using Composer by running the following command from your project's directory:

composer require airbrake/phpbrake

Example Usage

This usage example details how to create a notifier instance, set a global notifier instance, register the error handler, and includes a snippet of some code that would report an exception to Airbrake (You can find your project ID and API KEY with your project's settings):

// Create new Notifier instance.
$notifier = new Airbrake\Notifier(array(
    'projectId' => <Your project ID>,
    'projectKey' => '<Your project API KEY>',
));

// Set global notifier instance.
Airbrake\Instance::set($notifier);

// Register error and exception handlers.
$handler = new Airbrake\ErrorHandler($notifier);
$handler->register();

// Somewhere in the app...
try {
    throw new Exception('hello from phpbrake');
} catch(Exception $e) {
    Airbrake\Instance::notify($e);
}

Going further

Check out our official GitHub repo for info on additional features like:

JuKu commented 6 years ago

See #128 .