dbtlr/php-airbrake
PHP Airbrake is a deprecated PHP module for sending error messages to the Airbrake API via custom error and exception handlers. It still works for existing projects, but maintenance is minimal—new projects should use the official airbrake/phpbrake package.
Assessment up front: dbtlr/php-airbrake is explicitly deprecated by its author, who recommends the official airbrake/phpbrake package instead. It is not Laravel-aware, has no service provider or facade, and has had no release since June 2018. For a new Laravel project, do not adopt it. Use it only to maintain or extract an existing integration, then migrate to the official package.
If you inherit a codebase using it:
composer require dbtlr/php-airbrake
Confirm what Composer actually installed and whether it is compatible with your PHP runtime:
composer show dbtlr/php-airbrake
php -v
Minimal bootstrap:
use Airbrake\Client;
use Airbrake\Configuration;
$config = new Configuration(config('services.airbrake.key'), [
'environmentName' => app()->environment(),
'projectId' => config('services.airbrake.project_id'),
'appVersion' => config('app.version'),
'secure' => true,
]);
$client = new Client($config);
$client->notifyOnException($e);
Where to look first in vendor/dbtlr/php-airbrake:
src/Airbrake/Configuration.php — all supported options and defaults.src/Airbrake/Client.php — notifyOnException() and any custom-notice entry point.src/Airbrake/Filter/ — how notice payloads can be scrubbed before sending.First practical use case: wire it into Laravel's exception handler so uncaught exceptions in HTTP requests, queue workers, and console commands are reported with environment and version metadata.
1. Keep credentials in config/services.php and .env.
// config/services.php
'airbrake' => [
'key' => env('AIRBRAKE_KEY'),
'project_id' => env('AIRBRAKE_PROJECT_ID'),
],
AIRBRAKE_KEY=your-api-key
AIRBRAKE_PROJECT_ID=your-project-id
2. Bind a singleton in a service provider.
// app/Providers/AppServiceProvider.php
use Airbrake\Client;
use Airbrake\Configuration;
public function register()
{
$this->app->singleton('airbrake.client', function ($app) {
$config = new Configuration(config('services.airbrake.key'), [
'environmentName' => $app->environment(),
'projectId' => config('services.airbrake.project_id'),
'appVersion' => config('app.version'),
'secure' => true,
]);
return new Client($config);
});
}
3. Hook into Laravel's exception handler.
// app/Exceptions/Handler.php
public function report(Throwable $e)
{
if ($this->shouldReport($e) && app()->bound('airbrake.client')) {
$client = app('airbrake.client');
// The library is PHP 5.3-era and may type-hint \Exception.
// Wrap PHP 7+ Errors if the signature rejects Throwable.
if ($e instanceof \Exception) {
$client->notifyOnException($e);
} else {
$client->notifyOnException(
new \ErrorException($e->getMessage(), 0, E_ERROR, $e->getFile(), $e->getLine(), $e)
);
}
}
parent::report($e);
}
4. Report caught exceptions deliberately. Don't report everything; use it for exceptions that indicate a real operational problem, not expected validation failures:
try {
$this->chargeCustomer($order);
} catch (\PaymentGatewayException $e) {
app('airbrake.client')->notifyOnException($e);
throw $e;
}
5. Scrub sensitive data with filters. Exceptions often contain request parameters, tokens, and PII in messages or context. Implement the package's filter interface (check its exact signature in vendor/) and register it on the configuration before constructing the client:
$config->addFilter(new class implements \Airbrake\Filter\FilterInterface {
public function filter(array $notice)
{
$notice['error_message'] = preg_replace(
'/(password|token|secret)=[^&\s]+/i',
'$1=[FILTERED]',
$notice['error_message']
);
return $notice;
}
});
6. Use it in non-HTTP contexts. Laravel's handler covers queue jobs and Artisan commands, but long-running workers can hold stale client state. Make sure the singleton does not cache request-specific data across jobs/requests.
7. Add an explicit test path. In local and testing environments, either skip notification entirely or point to a non-production key:
if (app()->environment('production', 'staging') && config('services.airbrake.key')) {
// notify
}
8. Consider async delivery only if the package version supports it. The package has historically offered an async/queue mechanism. Check the Configuration options in your installed version. In Laravel, a safer pattern is to dispatch exception reporting through a queued job, keeping the user request fast.
airbrake/phpbrake. Treat any new work as migration work. Audit it before relying on it for production alerting.Handler::report().notifyOnException() may type-hint \Exception. In PHP 7+, Error and TypeError are Throwable but not Exception. Passing them directly can produce a TypeError. Wrap or convert as shown above.projectId, secure, and the host/endpoint in Configuration. Verify against your Airbrake project settings, not just the README.vendor/ rather than assuming API compatibility. The README is incomplete and the API changed over the package's lifetime. The installed source is the authoritative reference for method names, option keys, and filter signatures.composer.json, and avoid letting this dependency leak into shared libraries. When migrating to airbrake/phpbrake, centralize the client creation in one binding so only that file needs to change.dbtlr/php-airbrake binding with airbrake/phpbrake, keep the same notifyOnException() call site in Handler::report(), and move filters to the new package's filter API. Doing this behind a small internal interface (e.g. ExceptionReporter) makes the migration and future swaps trivial.How can I help you explore Laravel packages today?