Start tracking your errors

When you are writing code, creating advanced Fork CMS modules and themes, or adding new features, sometimes you break things. Fork CMS uses logs and can send you an email when an exception occurred, but for larger websites this becomes less useful because you don’t know if you’ve seen that issue before, or if it’s been fixed in the past by someone in your team. Moreover, you don’t know the severity of the issue. Has it occurred once or is this error popping up every 10 seconds? In this article, we explore the use of error tracking software such as Rollbar.

Rollbar error tracking

Put errors in their place

There are a lot of good error tracking products on the market: Airbrake, Rollbar, Bugsnag, Sentry or Errbit are just a few examples. In this blogpost we highlight one of them and give an example of how the integration in Fork CMS could work, but you can achieve the same with any other error-tracking product. 

Rollbar logoRollbar is an error tracking service for PHP and 15+ more languages. The Rollbar service will alert you of problems with your code and help you understand them in all kinds of ways. If you get an alert in Rollbar, you can dig in and see the history, discover the deployment that introduced this bug, see what user or browser it was related to, see different parameters, and more. Rollbar can track errors from “debug” to “critical” messages, so you can choose to only track an error when there is something severe going on.

The best thing? You can start using it with only a few lines of code and a free account that can track 5000 events per month with 30 days data retention, for unlimited projects, deploys and users.

Rollbar integration in Fork CMS

  1. Go to, register a free account and create a new php project. You will receive a server token and a spinner will appear that waits for your first error.
  2. Make sure you have an up-to-date monolog bundle in Fork CMS. This is the latest version and is being used in the latest Fork CMS, so make sure you have this in your composer.json:
    "symfony/monolog-bundle": "2.8.*"
  3. Add the official rollbar-handler to composer.json
    $ composer require rollbar/rollbar
  4. Configure monolog to use Rollbar:
    • Go to app/config/config.yml and look for monolog and add these changes:
            type:  stream
            path:  %site.path_www%/app/logs/%kernel.environment%.log
            level: debug
            type: rollbar
            token: %rollbar.token%
            level: warning
            bubble: true
                environment: %rollbar.environment%

You can configure other options too: see the configuration reference docs. See Monolog Log Levels to see which minimum level of log detail you'd like to track.

5. Add the rollbar token and environment to your app/config/parameters.yml file:

rollbar.token:          PASTE_SERVER_TOKEN_HERE
rollbar.environment:    'production'

That's it! Now wait for an exception to happen. You can also log warnings or errors yourself in your module code. Simply use the monolog logger in your modules like this, e.g:

$logger = $this->get('logger');
$logger->addNotice('This is logging a notice');
$logger->addError('This is logging an error');

If you'd like to track every javascript error too, have a look at the Javascript quick-start tutorial. It's really easy! Just include a script in your <head> as high as possible and you can start monitoring every occuring javascript error too!

Use Rollbar with Capistrano deployments

Capistrano is an advanced tool to deploy webapplications to your server. Fork CMS websites can be deployed using e.g. the ForkCMS deploy gem. To track each deploy, Rollbar offers functionality for capistrano deploys. Here are the basics with support for Capistrano 2.

  1. Add the gem to your gemfile, or install it manually using: 
    $ gem install rollbar --version=1.5.3
    The latests gems are for Capistrano 3, so we needed an older version of the gem.
  2. Add these lines in the deploy.rb capistrano script:
require 'rollbar/capistrano'

# Rollbar deploy integration
set :rollbar_token, 'POST_SERVER_ITEM_ACCESS_TOKEN'
set(:rollbar_env) { stage }

The last line uses the capistrano/multistage gem to make a distinction between staging/production, so if you don't use this gem you can remove that line. 

Now, do a deploy and go to the deploy tab in rollbar and you should see a summary of your deploys. Rollbar can even guide you to spot in which deploy a bug started occuring!



Use error tracking software such as Rollbar, Airbrake, Bugsnag, Sentry or Errbit when you create a complex website using Fork CMS. By monitoring errors, you can easily spot flaws and bugs, and have them fixed as early as possible before it affects a lot of visitors. Rollbar is an error tracker that is incredibly easy to start with and it offers a lot of functionality. You can use it to track errors in Fork CMS, keep track of your deploys and monitor javascript errors and more.