Author: Samuel Adeshina
Last month viewers: 1
Categories: PHP Tutorials, Sponsored
Therefore you always need to have a tool that can monitor the errors on the server side, so you can act promptly and fix issues as quickly as possible.
Read this tutorial to learn how you can use Rollbar to keep track of your PHP Web applications issues.
What exactly is Rollbar?
What are the benefits of Rollbar
Key Features of Rollbar
Most programmers, including me are diligent about writing the best code we can. This means error free software with very little or even zero downtime without sacrificing time and money.
We write tests, we check out our software on multiple browsers, platforms, devices and more. We try to do the best we can.
The sad truth is, it is nearly close to impossible to anticipate and test every possible scenario of our software. Then there is this nightmare of errors and exceptions occurring in situations that we did not plan for, and most of the time this happens in production environments.
As developers, no matter how much we try, we break a lot of things. What we break often show up in the form of uncaught exceptions, fatal errors, and all of those other weird bugs that seem to happen only on the server.
What if there was a way to manage these errors? What if there was a way to find and fix bugs faster, reduce troubleshooting, deploy software faster and increase productivity?
Most software projects are developed by a team of individuals, so what if we had a tool that could alert us in real time when an error has occurs or an exception is left uncaught by a member of the team?
This tool already exists, and its called Rollbar. I have personally used Rollbar for a number of my projects, and am excited to teach you how it can help you with yours. This article will be focused on what Rollbar is and how to use it to make your code error free, so your life as a developer becomes that much easier.
What exactly is Rollbar?
Rollbar is a full stack error monitoring platform. It makes it easy to find errors, reproduce them and fix bugs almost when they occur.
When errors occur in a PHP project on a production server for instance, the only way to find out is by digging through log files or by responding to customer support issues.
Rollbar works in a very simple way, it integrates into the ends (server and client) of an application and keeps looking for errors that happen during production and it reports them to developers in real time until you ask it to stop.
When errors occur, information about the errors (like the stack trace information and other contextual information) is collected, collated and reported to the public API where it is analyzed, deduped, and alerted in real time to the developers. The data is also prepared for further analysis for those of us that love crunching data.
What are the benefits of Rollbar
With Rollbar, not only do errors get detected, diagnosed and defeated in real time, it also gives powerful analytics and insights into the error ecosystem of any software code that has it integrated and enabled. It provides a rich querying interface to the error and exceptions data its accumulated from your code. It helps you experience how your users use your software.
You can determine which user experienced a specific error, and even reproduce that error. It helps you stay on top of support issues and helps to reach out to specific users when errors occurs and even when issues get resolved.
Key Features of Rollbar
1. Error Monitoring and Reporting
The primary objective behind Rollbar's existence is full stack error monitoring. Error detection and diagnostics are just a way in which this feature demonstrates itself.
This way, your entire software application gets monitored and errors, exceptions and those unforeseen bugs get reported and alerted as at when they occur.
One of the most interesting thing about the service is, the approach that was taken to make error reporting and issue tracking much more developer friendly.
Rollbar does not just report errors, it also adds the capability to specify the severity level of the kind of errors that occurred. This way, you get to choose which problems require the most attention and well, it also gives you an insight into how much code reviews you require.
2. Error queuing, deduping and grouping
What is the use of error reporting services if it is impossible for the service to tell when some errors do not need to be investigated? The nice thing about errors is that they usually repeat themselves and occur in similar groups.
The bad thing about the unorthodox method of logging them in files or other error reporting services is that these errors all get logged and reported, littering our inboxes with similar errors and making it an extra job to sort through the errors to find the more pressing unique ones. That is another problem Rollbar solves.
With Rollbar, errors get deduped. Deduplication is a technique for eliminating duplicate copies of repeating data. This means if twenty errors repeat themselves, you get alerted only once. This way you can focus on solving the unique problems instead of trying to sort through duplicate alerts of almost the same kind of errors.
They also allow you to group your errors into different categories, giving you the flexibility of choosing which errors and group of errors to pay attention to.
3. Error Analytics
My favorite part of the Rollbar experience is the attempt at exposing a rich querying interface for all the data Rollbar accumulates. This provides a means to get reasonable insight into the user experience of our software and helps us make factual decisions to improve every single phase of the software development life cycle and release processes.
RQL (Rollbar Query Language) enables you to query your database of Rollbar accumulated errors with statements that resemble the everyday SQL you and I use, and there's a dashboard with a nice analytics interface design. There's no limitation to how much you can learn from the errors and exceptions your apps throw.
Getting Started with Rollbar
The remaining part of this article will be focused on explaining how to integrate Rollbar into your PHP projects. The good news is it takes less than 5 minutes!
To be able to use Rollbar you need to register an account at https://rollbar.com/. They offer several plans based on the size of your teams and type of product you'd be using it for.
For the purpose of this tutorial, you can start with the free plan. Registration is as easy as entering your email address or clicking a button that asks to authorize the Rollbar app to authenticate with your GitHub account. You do have a GitHub account, right?
After signing up, you can sign into your account. On your dashboard, click "create a new project" and you will be presented with a form that asks you some information about the project you are trying to integrate with. Fill this form and submit to get your access tokens.
Your access tokens are the most important thing about the Rollbar integration process because they are what you need to feed to your codes to let them know they need to send reports to the Rollbar API.
Copy the access token marked as "server-side access token" to a safe place and follow the preceding instructions meticulously.
Add "rollbar/rollbar" to your composer.json file if you use composer. You can add the dependency by executing the following on the terminal:
composer require rollbar/rollbar.
Once you have downloaded and installed the dependency with composer, then you can add the following code to the entry point (preferably the index file in the root directory) of your project:
There you go! All your errors and uncaught exceptions will all get reported to Rollbar.
Everything I have already explained is just a tip of the iceberg of the entire Rollbar experience. Rollbar has other cool features like a Robust API for customizing anything to extending everything you want, down to the abiliity to specify your own custom Rollbar exceptions and errors from within your project source code.
Kill of the diagnostic and error monitoring bugs before they hatch. Get Rollbar.
If you liked this article, use the buttons above to share it with your PHP developer friends. If you have a question about Rollbar features, post a comment here.
You need to be a registered user or login to post a comment
Login Immediately with your account on: