baibaratsky/yii-rollbar

Rollbar Yii Extension

v2.3.3 2017-08-07 11:51 UTC

This package is auto-updated.

Last update: 2024-12-16 15:15:38 UTC


README

Packagist Dependency Status Packagist Packagist

Rollbar Yii Component is the way to integrate Rollbar service with your Yii 1.* application. For Yii2 use yii2-rollbar.

The code of this project has been forked from Ratchetio Component.

Installation

  1. The preferred way to install this component is through composer.

    To install, either run

    $ php composer.phar require baibaratsky/yii-rollbar:2.3.*
    

    or add

    "baibaratsky/yii-rollbar": "2.3.*"
    

    to the require section of your composer.json file.

  2. Add rollbar component to the main.php config:

    // ...
    'components' => array(
        // ...
        'rollbar' => array(
            'class' => 'application.vendor.baibaratsky.yii-rollbar.RollbarComponent', // adjust path if needed
            'access_token' => 'your_serverside_rollbar_token',
        ),
    ),
  3. Adjust main.php config to preload the component:

    'preload' => array('log', 'rollbar'),
  4. Set RollbarErrorHandler as error handler:

    'components' => array(
        // ...
        'errorHandler' => array(
            'class' => 'application.vendor.baibaratsky.yii-rollbar.RollbarErrorHandler',
            // ...
        ),
    ),

    You can also pass some additional rollbar options in the component config, refer to the Rollbar documentation for all available options.

    A good idea is to specify environment as:

    'environment' => isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'cli_' . php_uname('n'),

    You can specify alias of your project root directory for linking stack traces (application by default):

    'root' => 'root',

Rollbar Log Route

You may want to collect your logs produced by Yii::log() in Rollbar. Put the following code in your config and enjoy:

'components' => array(
    // ...
    'log' => array(
        // ...
        'routes' => array(
            array(
                'class' => 'application.vendor.baibaratsky.yii-rollbar.RollbarLogRoute',
                'levels' => 'error, warning, info',

                // You may specify the name of the Rollbar Yii Component ('rollbar' by default)
                'rollbarComponentName' => 'rollbar',
            ),
        ),
    ),
),