Yii 1.1: yii-rollbar

Rollbar Yii Component
1 follower

Rollbar Yii Component is the way to integrate Rollbar service with your Yii application. Rollbar aggregates and analyzes your application errors and deploys.

Installation

  1. a. Easy way is to use Composer. Just run composer install.

    OR

    b. Download rollbar.php and put it somewhere you can access, then add the following code at your application's entry point:

    require_once 'rollbar.php';
  2. Add rollbar component to the main.php config:

    // ...
    'components' => array(
        // ...
        'rollbar' => array(
            'class' => 'application.vendor.baibaratsky.yii-rollbar.RollbarComponent', // adjust path if needed
            'accessToken' => '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: environment, branch, maxErrno, baseApiUrl, etc.

    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):

    'rootAlias' => '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',
            ),
        ),
    ),
),

Be the first person to leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet