Configuration options

All available options for configuring Bugsnag with Symfony.

The Bugsnag client object has several methods which help you customize the content of error reports, and how the reports are delivered. Most configuration options can be automatically populated by environment variables and/or Symfony configuration within app/config/config.yml.

API key

You can set the Bugsnag API key by setting the BUGSNAG_API_KEY environment variable, or by setting api_key within app/config/config.yml:

bugsnag:
    api_key: YOUR-API-KEY-HERE

This setting is the only one which is required in order to use the notifier.

Auto notifying

Unhandled exceptions in your Symfony app will be automatically reported to your Bugsnag dashboard. You can the toggle auto notifying by setting auto_notify within app/config/config.yml:

bugsnag:
    auto_notify: true

By default, this is set to true.

App type

You can set the type of application executing the current code by using setAppType:

$this->get('bugsnag')->setAppType('Mailer');

You can also modify this within app/config/config.yml:

bugsnag:
    app_type: Mailer

By default this is set to Console or HTTP depending on the context.

App version

To track in which versions of your application each exception happens, set the app version:

$this->get('bugsnag')->setAppVersion('1.2.3');

You can also modify this within app/config/config.yml:

bugsnag:
    app_version: 1.2.3

Batch sending

If you’d like us to send the errors through to Bugsnag when the PHP process shuts down, in order to prevent your app waiting on HTTP requests, this can be set to true. Setting it to false will mean the we send an HTTP request straight away for each error.

$this->get('bugsnag')->setBatchSending(true);

You can also modify this within app/config/config.yml:

bugsnag:
    batch_sending: true

By default, this is set to true.

You can also flush our error buffer by calling the flush function, causing any queued errors to be sent immidiately:

$this->get('bugsnag')->flush(true);

Callbacks

Set a callback attached to the notification pipeline when notifying Bugsnag of an error. You can use this to call your own error handling functions or customize the error report.

$this->get('bugsnag')->registerCallback(function ($report) {
    // Inspect or modify the error report here
});

To cancel sending an error report, return false from the function.

Endpoint

You can change the Bugsnag endpoint by setting the BUGSNAG_ENDPOINT environment variable, or by setting endpoint within app/config/config.yml:

bugsnag:
    endpoint: https://example.com

By default, this is set to https://notify.bugsnag.com.

Error reporting level

Set the levels of PHP errors to report to Bugsnag. This is set to the value of error_reporting from your php.ini or any value you set at runtime using the error_reporting(...) function by default.

$this->get('bugsnag')->setErrorReportingLevel(E_ALL & ~E_NOTICE);

See PHP’s error reporting documentation for allowed values.

Filters

Sets the strings to filter out from the metaData arrays before sending them to Bugsnag. Use this if you want to ensure you don’t send sensitive data such as passwords, and credit card numbers to our servers. Any keys which contain these strings will be filtered.

$this->get('bugsnag')->setFilters(['password', 'credit_card']);

You can also modify these within app/config/config.yml:

bugsnag:
    filters:
        - password
        - credit_card

By default, this is set to be ['password'].

Hostname

If you would like to set the hostname of your server to something specific for you to identify it by, then you can call this method with your desired hostname.

$this->get('bugsnag')->setHostname('your-hostname');

You can also modify this within app/config/config.yml:

bugsnag:
    hostname: your-hostname

By default this is set to php_uname('n').

Proxies

If you’d like to set a proxy for us to use, you can set the HTTP_PROXY or HTTPS_PROXY variables for Guzzle.

Note that HTTP_PROXY is only available in cli, and if HTTPS_PROXY is present, it’ll replace HTTP_PROXY.

Metadata

Here you can set additional metadata to send with every bugsnag notification. By default, we merge your new metadata with anything already existing on the config object. You can pass false as the 2nd parameter to disable this behaviour.

$this->get('bugsnag')->setMetaData([
    'account' => [
        'paying' => true,
        'name' => 'Acme Co'
    ]
]);

Project root

Bugsnag marks stacktrace lines as in-project if they come from files inside your “project root”. This can be set by calling setProjectRoot on our client.

It also trims this path from the start of any filepath. If you want to change the strip path, you can call the setStripPath function.

$this->get('bugsnag')->setProjectRoot('/path/to/your/app/src');
$this->get('bugsnag')->setStripPath('/path/to/your/app');

You can also modify these within app/config/config.yml:

bugsnag:
    project_root: /path/to/your/app/src
    strip_path: /path/to/your/app

By default, we’ll set your src folder as the project root, and the strip path to be one directory above that.

Release stage

If you would like to distinguish between errors that happen in different stages of the application release process (development, production, etc) you can set the releaseStage that is reported to Bugsnag.

$this->get('bugsnag')->setReleaseStage('development');

By default, we’ll automatically detect the app environment by looking at kernel.environment, and Bugsnag is notified of errors that happen in any releaseStage.

If you would like to change which release stages notify Bugsnag of errors you can call setNotifyReleaseStages.

$this->get('bugsnag')->setNotifyReleaseStages(['development', 'production']);

You can also modify these within app/config/config.yml:

bugsnag:
    notify_release_stages:
        - development
        - production

Sending code

Bugsnag automatically sends a small snippet of the code that crashed to help you diagnose even faster from within your dashboard. If you don’t want to send this snippet, you can call setSendCode:

$this->get('bugsnag')->setSendCode(false);

You can also modify this within app/config/config.yml:

bugsnag:
    send_code: false

By default, this is set to true.