Configuration options

All available options for configuring Bugsnag with Laravel.

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 or in config/bugsnag.php, to generate it run php artisan vendor:publish.

If you have previously generated a config cache in your environment, re-run php artisan config:cache after making any changes to configuration or environment variables. See Laravel’s documentation for more information.

API key

You can set the Bugsnag API key by setting the BUGSNAG_API_KEY environment variable, or by setting api_key within config/bugsnag.php

'api_key' => 'YOUR-API-KEY-HERE',

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

App type

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

Bugsnag::setAppType('Mailer');

You can also set the BUGSNAG_APP_TYPE environment variable, or set this within config/bugsnag.php:

'app_type' => 'Mailer',

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

App version

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

Bugsnag::setAppVersion('1.2.3');

You can also set the BUGSNAG_APP_VERSION environment variable, or set this within config/bugsnag.php:

'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.

Bugsnag::setBatchSending(true);

You can also set the BUGSNAG_BATCH_SENDING environment variable, or set this within config/bugsnag.php:

'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:

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.

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 config/bugsnag.php:

'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.

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.

Bugsnag::setFilters(['password', 'credit_card']);

You can also set the BUGSNAG_FILTERS environment variable to a comma seperated string such as password,credit_card.

Finally, this could be set within config/bugsnag.php:

'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.

Bugsnag::setHostname('your-hostname');

You can also set the BUGSNAG_HOSTNAME environment variable, or set this within config/bugsnag.php:

'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.

You can also set these options within config/bugsnag.php. For example, to set an HTTPS proxy:

'proxy' => ['https' => 'https://example.com'],

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.

Bugsnag::setMetaData([
    'account' => [
        'paying' => true,
        'name' => 'Acme Co'
    ]
]);

To set metadata on error reports individually, see customizing error reports.

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.

Bugsnag::setProjectRoot('/path/to/your/app/src');
Bugsnag::setStripPath('/path/to/your/app');

You can also set the BUGSNAG_PROJECT_ROOT and/or BUGSNAG_STRIP_PATH environment variables, or set these within config/bugsnag.php:

'project_root' => '/path/to/your/app/app',
'strip_path' => '/path/to/your/app',

By default, as long as you provide us a strip path, we’ll assume your project root is the app directory.

Query breadcrumbs

Bugsnag automatically captures database queries as breadcrumbs. To turn this off you can set the BUGSNAG_QUERY environment variable to false.

By default, we exclude query bindings from the breadcrumbs. If you’d like to include these, set BUGSNAG_QUERY_BINDINGS to true.

You can also modify these within config/bugsnag.php:

'query' => true,
'bindings' => true,

See automatically captured breadcrumbs for more information.

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.

Bugsnag::setReleaseStage('development');

You can also set the BUGSNAG_RELEASE_STAGE environment variable, or set this within config/bugsnag.php:

'release_stage' => 'development',

By default, we’ll automatically detect the app environment by calling the environment() function on Laravel’s application instance.

Bugsnag is notified of errors that happen in any release stage. If you would like to change which release stages notify Bugsnag of errors, you can call setNotifyReleaseStages.

Bugsnag::setNotifyReleaseStages(['development', 'production']);

You can also set the BUGSNAG_NOTIFY_RELEASE_STAGES environment variable to a comma seperated string such as development,production.

Finally, this could be set within config/bugsnag.php:

'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:

Bugsnag::setSendCode(false);

You can also set the BUGSNAG_SEND_CODE environment variable, or set this within config/bugsnag.php:

'send_code' => true,

By default, this is set to true.