i22/airbrake-bundle

Airbrake.io integration for Symfony

Installs: 1 944

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 5

Forks: 12

Open Issues: 0

Type:symfony-bundle

v2.0.7 2017-11-02 10:07 UTC

README

Latest Stable Version Dependencies Status

Airbrake.io & Errbit integration for Symfony.

Notes

This project is a fork of eymengunay/EoAirbrakeBundle (big thanks). We used it a lot for our own projects, but sadly its no longer active maintained. so we decided to fork it and push it a little. e.g. with twig 2.0+ the current twig extension is deprecated and has to be replaced. further we will also switch from dbtlr/php-airbrake to the official airbrake/airbrake-php.

Prerequisites

This version of the bundle requires Symfony 3.2+

Installation

Step 1: Download AirbrakeBundle using composer

Add AirbrakeBundle in your composer.json:

{
    "require": {
        "i22/airbrake-bundle": "~2.0"
    }
}

Now tell composer to download the bundle by running the command:

$ php composer.phar update i22/airbrake-bundle

Composer will install the bundle to your project's vendor/i22 directory.

Step 2: Enable the bundle

Enable the bundle in the kernel:

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new I22\AirbrakeBundle\I22AirbrakeBundle(),
    );
}

Step 3: Configure the I22AirbrakeBundle

Now that you have properly installed and enabled I22AirbrakeBundle, the next step is to configure the bundle to work with the specific needs of your application.

Add the following configuration to your config.yml file

# app/config/config.yml
i22_airbrake:
    project_id: PROJECT-ID
    api_key: YOUR-API-KEY

Step 4 (Optional): Add host configuration to point to a self hosted solution like errbit

# app/config/config.yml
i22_airbrake:
    ...
    host: YOUR-ERRBIT-HOST
    ...

Step 5 (Optional): Add I22AirbrakeBundle routing to simulate an error exception:

If you want to simulate an exception and test your configuration you can add the following route in your application.

# app/config/routing.yml
i22_airbrake_simulate:
    pattern: /airbrake/simulate
    defaults:  { _controller:  I22AirbrakeBundle:Simulate:index }

You will now be able to access the example controller from: http://your-project.domain/airbrake/simulate

Configuration reference

i22_airbrake:

    # This parameter is required
    # For Errbit the exact value of project_id doesn't matter
    project_id:: YOUR-PROJECT-ID

    # Omit this key if you need to enable/disable the bundle temporarily 
    # If not given, this bundle will ignore all exceptions and won't send any data to remote.
    api_key: YOUR-API-KEY

    # By default, the notifier uses a socket connection to send the exceptions to Airbrake, 
    # which WON'T wait for a response back from the server. 
    # If this is not derisable for your application, you can pass async: false 
    # and the notifier will send an syncronous notification using cURL.
    async: true

    # If you are using your own hosted implementation of 
    # Airbrake (such as Errbit) you will have to specify your custom host name.
    host: errbit.example.com

    # You might want to ignore some exceptions such as http not found, access denied etc.
    # By default this bundle ignores all HttpException instances. (includes HttpNotFoundException, AccessDeniedException)
    # To log all exceptions leave this array empty.
    ignored_exceptions: ["Symfony\Component\HttpKernel\Exception\HttpException"]

    # If you want to force override of whether or not to use SSL you can set secure to true/false whether or not to use SSL you can set secure to true/false
    # By default secure is set to true
    secure: true

Usage

Once configured, bundle will automatically send exceptions/errors to airbrake server.

Logging javascript errors

EoAirbrakeBundle includes a twig extension for airbrake javascript notifier. To start logging exceptions on client side you have to add {{ airbrake_notifier() }} function in your base template:

<!doctype html>
<html lang="en">
    <head>
        <title>Hello World</title>
        <!-- Airbrake notifier -->
        {{ airbrake_notifier() }}
    </head>
...

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

Reporting an issue or a feature request

Issues and feature requests related to this bundle are tracked in the Github issue tracker https://github.com/i22-digitalagentur/AirbrakeBundle.