Laravel Error Tracking

Typical installation time: 5 minutes

Hi there! You've found Honeybadger's guide to Laravel error tracking. Once installed, Honeybadger will automatically report errors wherever they may happen:

  • During a web request
  • In a scheduled command
  • In a background task
  • When a process crashes

On this page:


First, install the honeybadger-laravel package via composer:

composer require honeybadger-io/honeybadger-laravel

Note: This package uses Laravel's package discovery to register the service provider and facade to the framework. If you are using an older version of Laravel or do not use package discovery, you may need to manually register those components.

Next, add Honeybadger reporting to app/Exceptions/Handler.php:

public function report(Exception $exception)
    if (app()->bound('honeybadger') && $this->shouldReport($exception)) {
        app('honeybadger')->notify($exception, app('request'));


Finally, run the honeybadger:install artisan command:

php artisan honeybadger:install project-api-key

The honeybadger:install command does three things:

  1. Adds HONEYBADGER_API_KEY to .env and .env.example
  2. Creates Honeybadger's config/honeybadger.php configuration file
  3. Sends a test notification to your Honeybadger project

If everything is set up correctly, you should now have an error report in Honeybadger!

Identifying Users

The following middleware will add the user's auth identifier context automatically. This middleware should be applied after any middleware that handles authentication:

// app/Http/Kernel.php
protected $middlewareGroup = [
    'web' => [

Adding Context

Context can be added by either the provided Facade or by resolving from the service container.


Honeybadger::context('key', $value);

DI Resolution

use Honeybadger\Honeybadger;

public function __construct(Honeybadger $honeybadger)
    $honeybadger->context('key', $value);

Helper Resolution

use Honeybadger\Honeybadger;

public function __construct()
    app('honeybadger')->context('key', $value);
    app(Honeybadger::class)->context('key', $value)


honeybadger-laravel integrates with Honeybadger's Check-In feature to help you know when your scheduled tasks and background jobs go missing or silently fail.

Scheduled Command

This method is great for ensuring your application is up and running.

// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
    $schedule->command('honeybadger:checkin 1234')->everyFiveMinutes();

After a Scheduled Command

This method is great for making sure specific scheduled commands are running on time.

// app/Console/Kernel.php
protected function schedule(Schedule $schedule)


> php artisan honeybadger:checkin 1234