Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Airbrake Bundle Laravel Package

realestateconz/php-airbrake-bundle

A Symfony bundle that integrates the Airbrake PHP notifier to automatically report exceptions and errors to Airbrake for centralized monitoring. Offers simple configuration for API credentials, environment settings, and exception filtering.

View on GitHub
Deep Wiki
Context7

Getting Started

This bundle is a thin Symfony 2 wrapper around php-airbrake, so treat it as "two moving parts": the bundle (DI, config, service wiring) and the php-airbrake client (the actual HTTP notifier). Before writing code, open the bundle's DependencyInjection/Configuration.php and Resources/config/services.xml to confirm the exact config root and service id — the service is typically exposed as php_airbrake (wrapping Airbrake\Client).

Minimal steps:

  1. Install (composer if available for the era, otherwise deps/git submodule):
    composer require realestateconz/php-airbrake-bundle
    
  2. Register in app/AppKernel.php:
    new RealestateConz\PhpAirbrakeBundle\RealestateConzPhpAirbrakeBundle(),
    
  3. Configure in app/config/config.yml (keep secrets in parameters.yml):
    realestate_conz_php_airbrake:
        api_key: "%airbrake_api_key%"
    
  4. Smoke-test from a controller:
    $airbrake = $this->get('php_airbrake');
    $airbrake->notifyOnException(new \Exception('smoke test'));
    
  5. Check your Airbrake dashboard; if nothing arrives, you're usually on the wrong API endpoint or the request died before the client flushed.

First real use case: production exception reporting. Enable only in prod, wire a kernel.exception listener, and verify a 500 lands in Airbrake. Everything else (manual notifications, custom context) comes after that works.

Implementation Patterns

Central exception listener (the pattern you actually want). Don't sprinkle notifyOnException through controllers. Register a listener on kernel.exception:

class AirbrakeExceptionListener
{
    public function __construct(private $airbrake, private $enabled) {}

    public function onKernelException(GetResponseForExceptionEvent $event)
    {
        if (!$this->enabled) {
            return;
        }
        try {
            $this->airbrake->notifyOnException($event->getException());
        } catch (\Exception $e) {
            // never let reporting break the app
        }
    }
}

Tag it kernel.event_listener with event: kernel.exception and priority: -128 so it runs after your own handlers have had a chance.

Environment gating. Keep the bundle config simple and gate the listener on %kernel.environment% or a dedicated airbrake_enabled parameter. Reporting from dev and test is noise — restrict to prod and, at most, a staging env.

Custom context on every notice. Wrap notifications in small helpers that attach request/user data:

$airbrake->notifyOnException($e, [
    'component' => 'checkout',
    'action'    => $request->attributes->get('_route'),
    'params'    => ['user_id' => $user?->getId()],
]);

(Confirm the second-argument signature against the bundled php-airbrake version — older releases use notifyOnException($e, $params) or a separate $client->notify() call.)

Service injection over container lookups. In Symfony 2 you can call $this->get('php_airbrake'), but injecting it into your own services keeps testing simple — register a small AirbrakeReporter service and type-hint that instead.

Console commands. kernel.exception fires for HTTP requests; long-running or CLI failures won't reach your listener. Add a console.exception listener (or wrap Command::execute in try/catch) that calls the same notifier.

Filtering. Airbrake dashboards drown in 404s and expected domain exceptions. Either check exception class in the listener before notifying, or use the client's ignoreExceptions/filter config if the version exposes it.

Testing. Inject a fake notifier that records exceptions in-memory so you can assert "this endpoint reports to Airbrake" without hitting the network. Keep the real client out of test.

Gotchas and Tips

This is ancient. The bundle targets Symfony 2 and the old php-airbrake client. It almost certainly does not work as-is on Symfony 3+ (event signature changes: GetResponseForExceptionEvent → ExceptionEvent, getException() → getThrowable()) or PHP 8. Budget for a fork or replacement before you depend on it, and treat the "score 0 / no dependents" as a signal: no one is maintaining this against modern Symfony.

API endpoint drift. php-airbrake speaks Airbrake's older notifier API. Newer Airbrake accounts use v3 endpoints and project IDs; if notices silently vanish, check the configured host/endpoint in the client config, not just the API key.

Never let reporting throw. A failing notifier that bubbles an exception turns one 500 into a cascading failure (and can cause recursion if the listener itself errors). Always wrap notifyOnException in try/catch inside your listener.

Secrets. Don't put api_key in a committed config.yml. Use parameters.yml/parameters.yml.dist, or environment variables picked up via %env(...)% in newer Symfony — but note the old php-airbrake client won't read env vars directly, so you'll resolve them into parameters.

Container is cached. If you change the config root or API key and nothing changes, clear the cache (app/console cache:clear --env=prod). Symfony 2's DI container is compiled; a stale cache is the #1 reason "my config isn't taking effect."

Double reporting. If you already have a generic error handler or Monolog FingersCrossed handler that emails/logs, you can report the same exception twice. Decide on a single source of truth (Airbrake for unexpected 500s, Monolog for the rest) and filter accordingly.

Debugging a silent client. Put a var_dump/log line right before notifyOnException and once inside a minimal try { $client->notify(...); } call. If the notify call is reached but nothing arrives, it's transport (endpoint/API key/network); if it's not reached, your listener isn't registered or is gated off.

Extension points. The cleanest place to customize is your own wrapper service plus a listener — don't patch the bundle. If you need Symfony 3+, fork the bundle and update the exception listener signatures; the client itself may still work for basic v2 notices.

Version pinning. Pin both the bundle and php-airbrake in composer.json. This ecosystem has no semver discipline from 2012-era packages and an unpinned update can silently break the notifier.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin