How to construct a Bugsnag client manually when you need additional control over the transport and metadata sent.
To create a fully customized Bugsnag integration, use the client constructor
instead of the default
// Configuration options used $config = new Bugsnag\Configuration("YOUR-API-KEY"); // Request resolver. The basic resolver resolves the current request. $resolver = new Bugsnag\BasicResolver(); // Customizable HTTP client $guzzle = new GuzzleHttp\Client(['base_uri' => Bugsnag::ENDPOINT]); $bugsnag = new Bugsnag\Client($config, $resolver, $guzzle);
At this point, the
$bugsnag instance can be used directly to send error
and exception reports. Each of the constructor arguments can be modified as
needed to better suit your use case. Below are a few common examples.
If you require using a proxy or a custom timeout length when sending error
reports to Bugsnag, you can create a
Bugsnag\Client instance with a customized
HTTP client via Guzzle. The example in
creating a custom client would instead construct
$guzzle with additional parameters:
// Customizable HTTP client $guzzle = new GuzzleHttp\Client(['base_uri' => Bugsnag::ENDPOINT, 'timeout' => 30, 'proxy' => 'tcp://localhost:8125']);
After constructing a custom Bugsnag client, you can register callbacks to collect
information about the state of the application when the error occurred. To
collect all of the metadata
by the default configuration in the
integration guide, use
A Bugsnag client can be modified using the configuration options provided. The transport method of an existing client is immutable; to change the transport method (such as the endpoint or proxy), construct a new Bugsnag client using the transport options.