/ laravel

Better bug tracking with Bugsnag + Laravel

Were you ever forced to go through the long laravel.log files looking to track an user's error? Well, I did, and I can assure you that it's not a good experience.

Bugsnag is a web platform that not only notifies you about the expections thrown at your website, but also provides you with a superb interface to review the details on the expection, request and even the stack trace.


Bugsnag supports dozens of notification platform. From the plain old email, to directly pinging your team's HipChat or even opening a GitHub issue directly in your repository, this is surely a great feature.

There is even a project that will use the web hook notification feature to ring an alarm for 5 minutes so you won't forget about the exceptions.

Laravel Integration

Fortunately for us, the Busgnag team worked hard on getting readymade implementations for the most common platforms: Android, Java, Android, iOS, PHP or even Node.JS, just to mention some.

We will cover the setup of Bugsnag with Laravel, but the process for other platforms shouldn't be much different.

1. Installing the Package

With Composer, installing third-party packages is painless.

Just run:

$ composer require "bugsnag/bugsnag-laravel:1.*"

And you're done. You just need to tell Laravel to use the Bugsnag Service Provider and set the Bugsnag Facade.

To do so, you need to update the app/config/app.php file:

# Add `BugsnagLaravelServiceProvider` to the `providers` array
'providers' => array(

# Add the `BugsnagFacade` to the `aliases` array
'aliases' => array(
    'Bugsnag' => 'Bugsnag\BugsnagLaravel\BugsnagFacade',

Now you need to publish the config file:

$ php artisan config:publish bugsnag/bugsnag-laravel

And then update the config at app/config/packages/bugsnag/bugsnag-laravel/config.php

A extremely useful option that Bugsnag provides, is to filter out some environments. It's not exactly useful to have the local development exceptions since you probably have the debug set to true.

To do so, update the previous file with this, with modifications as needed:

'notify_release_stages' => ['production', 'staging']

You can browse through the bugsnag-laravel repository on GitHub for some extra features.

Finally, an option that I find extremely useful is to set the Bugsnag UserID (that is usually kind of random) to the user ID of your app, or even the user's email.

Add the following to your app/start/global.php:


Now when you browse through your exceptions, you can immediately tell if the user was authenticated, and which user was it.

This pretty much sums it up. If you want a simple yet really effective solution to manage your application log, Bugsnag is definitely the way to go.

Rui Gomes

Rui Gomes

Web Developer, Internet Marketing enthusiast and Student@FEUP. That pretty much sums it up.

Read More