Rollbar is Awesome

Ever wanted to see errors happening on your application? I use rollbar for this. And unless your app has over 5000 errors a month, it is free.

Installing Rollbar for Laravel is super easy. Below is the code you get when you first sign up for Rollbar.

// installs global error and exception handlers
Rollbar::init(array('access_token' => 'YOUR_ACCESS_TOKEN_HERE'));

// Message at level 'info'
Rollbar::report_message('testing 123', 'info');

// Catch an exception and send it to Rollbar
try {
    throw new Exception('test exception');
} catch (Exception $e) {

// Will also be reported by the exception handler
throw new Exception('test 2');

You’ll also want to install rollbar library with composer.

composer require rollbar/rollbar

Next, where to place the error handling code? In Laravel 5, you’ll want to add it to app\Exceptions\Handler.php like so…

     * Report or log an exception.
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     * @param  \Exception  $e
     * @return void
    public function report(Exception $e)
        // use this rollbar for production environments
        if (config('app.env') === 'production')
            Rollbar::init(array('access_token' => 'YOUR_PROD_ACCESS_TOKEN'));


        // maybe use your own DEV rollbar here?
        if (config('app.env') === 'local')
            Rollbar::init(array('access_token' => 'YOUR_DEV_ACCESS_TOKEN'));



This tool will keep track of all the errors your visitors are seeing. It doesn’t replace writing tests for the application necessarily but it does give an extra layer of comfort knowing when your application is erroring. Some times you can find and fix errors before a client has time to email you that screenshot and upload it to JIRA or Trello. Then you just say, yeah, I fixed that like 5 minutes ago dawg…* and walk off with a gangsta smile on your face.

post by Kelt Dockins on 11/19/2015