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
.
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.
Unhandled exceptions in your Symfony app will be automatically reported to your BugSnag dashboard. You can toggle auto notifying by setting auto_notify
within app/config/config.yml
:
bugsnag:
auto_notify: true
By default, this is set to true
.
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.
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
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 immediately:
$this->get('bugsnag')->flush(true);
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.
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
.
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']
.
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')
.
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
.
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'
]
]);
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.
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');
You can also modify this within app/config/config.yml
:
bugsnag:
release_stage: 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
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
.
You enable or disable user information collection by using setUser
:
$this->get('bugsnag')->setUser(false);
You can also modify this within app/config/config.yml
:
bugsnag:
user: false
By default, this is set to true
.