I stumbled across a great application called Rollbar which logs application error in a variety of languages such as Php, Perl, Javascript and Ruby to name but a few. It also has integration with Trello, Slack and Github.

When i’m writing small Laravel applications. Whenever an error occured in my application I used to ssh into the error logs and figure out what was the problem. It’s not ideal but my Laravel sites are small personal projects. So I could never justify getting an error logging service.

I came across Rollbar on one of the podcasts I listen to it has loads of features and as a free tier for small appliactions which is perfect for me. I want go through the process of integrating it into a Laravel project and setting it up with Laravel Envoyer.

I’m going to assume you currently have a Rollbar account they have a free tier with no credit card needed for signup and it’s straightforward to do so, I’m also going to assume you have a Laravel application with Envoyer for Deployments. But Envoyer isn’t essential as this is only for deployment monitoring.

Rollbar

On the Dashboard click on Integrate a Notifier. Now from the list of Languages select PHP. On this page make a copy of the server-side key.

Laravel

Go to composer.json file for your application and add the following package “jenssegers/rollbar”: “^1.5” under require. This is great package which makes the Rollbar integration straightforward.

With the package added now go to the command line for you application do a composer update.

Now open up the following file config/app.php. We need to add the rollbar package as an application service provider. In providers array add in the following snippet.

Jenssegers\Rollbar\RollbarServiceProvider::class,

We now need to change how the existing errors are getting logged this is done in the following file app/Exceptions/Handler.php. In this file go to the report function and replace the code with the following below.