honeybadger-io/honeybadger-laravel
Honeybadger for Laravel integrates Honeybadger.io error monitoring into your app, automatically reporting exceptions and logs with rich context. Configurable via a single config file, it also supports custom notifications and deploy tracking.
composer require honeybadger-io/honeybadger-laravel, then run php artisan honeybadger:install. It publishes config/honeybadger.php, prompts for your API key, writes HONEYBADGER_API_KEY into .env, and fires a test notification.config/app.php. Set HONEYBADGER_ENVIRONMENT (or let it fall back to APP_ENV) per environment and keep the key out of the repo.php artisan honeybadger:test before touching any code, and again after upgrading to v5.1.0 — this release changes the default event pipeline, so verify what actually lands in the dashboard.config/honeybadger.php: the handlers array (what is captured automatically), the events section (Insights telemetry, now on by default), and the exceptions filtering rules. That file, not your Handler class, is where most day-to-day behaviour is tuned.Honeybadger::context([...]) call in a middleware to attach user_id, tenant, and request identifiers — this is the highest-value change you can make in the first hour.Honeybadger::notify($throwable) for caught exceptions, Honeybadger::addBreadcrumb('message', ['category' => 'custom', 'metadata' => [...]]) to enrich the trail leading to a fault.notify() for caught exceptions you deliberately swallow (third-party API failures, webhook processing) where the surrounding context is more useful than a stack trace.Honeybadger::context(['user_id' => auth()->id(), 'tenant' => tenant()->id, 'request_id' => $request->header('X-Request-Id')]) early in the stack. In stateless requests it's implicitly per-request; see the long-running caveat below.Honeybadger::event('order.completed', ['order_id' => $order->id, 'total_cents' => $order->total]) is a cheap way to get queryable product telemetry next to your errors. Use it for low-cardinality, meaningful domain moments — signups, payment outcomes, integration failures — not for debug chatter.honeybadger channel in config/logging.php and use Log::channel('honeybadger')->warning(...) for conditions that aren't exceptions but still deserve visibility (deprecated API usage, degraded dependency, retry exhaustion). With 5.1.0's defaults, check whether your existing log events are already being forwarded before adding duplicate channels.handle() rather than in the constructor, since serialized properties may contain sensitive data. If you need per-job grouping, set a custom fingerprint or tag via context keys.Honeybadger::checkin('nightly-reconcile') into the task's success callback (->onSuccess() / ->then()) so Honeybadger alerts on absence of runs, not just failures. This catches a silent scheduler or a hung worker that no exception would ever surface.php artisan honeybadger:deploy --environment=production --revision=$GIT_SHA to your pipeline (Forge/Envoyer deploy script, GitHub Actions, etc.). This needs the personal API key, not the project key — the single most common source of 401s here.RequestTerminated/JobProcessed listeners, or scope them tightly inside the middleware/job that sets them.Honeybadger::event() — now flow unless you turn them off. Before upgrading production: audit the events block in config/honeybadger.php, confirm no request bodies, headers, or user identifiers are being shipped that shouldn't be, and disable in local/testing. Expect a data-volume (and quota) change even if you change nothing else.honeybadger:test and check the Insights view specifically — a green "exception arrived" signal doesn't prove the event pipeline is working.$dontReport / $exceptions->dontReport() for classes you never want, and the package's exceptions config for filters (ignored messages, environment gating). Validation and 404-style exceptions are already excluded by Laravel's default reporting rules — don't re-report them from custom middleware.php artisan config:cache freezes HONEYBADGER_* values. Changing an env var on Forge/Envoyer without re-caching or redeploying leaves the old value live, which looks exactly like "the key is wrong."exit()/dd() paths, or fatal-error scenarios, call Honeybadger::flush() (or the events-specific flush) before terminating, or you'll debug missing data for an hour.project_root and containers. Stack-trace file paths are made relative to project_root (defaults to base_path()). If you build in one directory and run in another (multi-stage Docker), paths won't line up and grouping/source links degrade.honeybadger log driver for non-exception signals, Honeybadger::addBreadcrumb() for custom trails around flaky integrations, and check-ins for anything scheduled. Combined with the now-default event stream, these cover most "it broke and nobody knew" cases without writing custom alerting.How can I help you explore Laravel packages today?