evolution7/bugsnag-bundle

Bugsnag error reporting integration for Symfony2

Installs: 9 563

Dependents: 0

Stars: 3

Watchers: 11

Forks: 5

Open Issues: 1

Language: PHP

1.2.1 2015-07-22 07:40 UTC

README

Enables Bugsnag integration into your Symfony2 application, using the bugsnag-php 2.x library from Bugsnag.

Installation

The recommended way of installing this bundle is using Composer.

Add this repository to your composer information using the following command

composer require "evolution7/bugsnag-bundle:1.*"

Add the bundle to your AppKernel.php:

$bundles = array(
    //Other Bundles
    new Evolution7\BugsnagBundle\BugsnagBundle(),

Define your Bugsnag API key in the config.yml

bugsnag:
    api_key: YOUR-API-KEY

Usage

After the installation the bundle works without any additional settings required, but you can tweak some settings.

Notify Stages

You can set for which environments you want Bugsnag to get error reports. This is done with the notify_stages setting:

bugsnag:
    notify_stages: [development, staging, production]

The default is to report bugs in staging and production environments.

Development mode

By default errors in development (app_dev.php) mode will not be reported to Bugsnag. You can override this behaviour with the below setting.

bugsnag:
    report_in_dev: true

Proxy

If your server requires you to access Bugsnag through a proxy, you can set this up easily as well. Just use the following example to configure the settings you need in your config.yml:

bugsnag:
    proxy:
        host: www.bugsnag.com
        port: 42
        user: username
        password: password

The only of these settings that is mandatory is the host, all others can be left out if they aren't required.

AppVersion

If you tag your app releases with version numbers, Bugsnag can display these on your dashboard if you set this:

bugsnag:
    app_version: v1.2.3

Testing

Included in the bundle is a controller that will allow you to test if your site is hooked up correctly. Just add the following to your routing.yml:

evolution7_bugsnag_bundle:
    resource: "@BugsnagBundle/Resources/config/routing.yml"
    prefix:   /bugsnagtest

And then afterwards you can access your.domain/bugsnagtest/exception and your.domain/bugsnagtest/error which should then send errors to your configured Bugsnag project.

Advanced Usage

Release Stage Class

Bugsnag allows you to determine which release stage you are currently in, the Evolution7BugsnagBundle uses a ReleaseStage class for this which determines this based on the path. Depending on your setup you might want to have a different way of determining this, in which case it is possible to override this by providing your own ReleaseStage class. You can implement a class that implements the Evolution7\BugsnagBundle\ReleaseStage\ReleaseStageInterface and provide its name as a parameter in your config.yml

bugsnag:
    release_stage:
        class: Your\Name\Space\ClassName

Contributing

  • Fork it on Github
  • Commit and push until you are happy
  • Run the tests to make sure they all pass: composer install && ./vendor/bin/phpunit
  • Make a pull request
  • Thanks!

Acknowledgement

Parts of this code are based on the bugsnag-php-symfony Bundle