Skip to content

eroteev/yii2-rollbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rollbar for Yii2

Simplified rollbar monitoring integration for Yii2 applications.

Installation

The preferred way to install this extension is through composer.

To install add

"eroteev/yii2-rollbar": "^1.0.0"

to the require section of your composer.json file.

Setup instructions

  1. Add the component configuration in your global config file:
'bootstrap' => ['rollbar'],
'components' => [
    'rollbar' => [
        'class' => 'eroteev\rollbar\Rollbar',
        'config' => [
            'access_token' => 'POST_SERVER_ITEM_ACCESS_TOKEN',
        ]
    ],
],
  1. Add the web error handler configuration in your web config file:
'components' => [
    'errorHandler' => [
        'class' => 'eroteev\rollbar\error_handler\WebErrorHandler'
    ],
],
  1. Add the console error handler configuration in your console config file:
'components' => [
    'errorHandler' => [
        'class' => 'eroteev\rollbar\error_handler\ConsoleErrorHandler'
    ],
],
  1. Add log target in your global config file:
'log' => [
    'targets' => [
        [
            'class' => 'eroteev\rollbar\log\RollbarTarget',
            'levels' => ['error'], // Log levels you want to appear in Rollbar
            'categories' => ['application'],
        ],
    ],
],

Ignore specific exceptions

To ignore specific exceptions you can update the component configuration in your global config file:

'components' => [
    'rollbar' => [
        'class' => 'eroteev\rollbar\Rollbar',
        'config' => [
            // ...
            'check_ignore' => function ($isUncaught, $toLog, $payload) {
                return eroteev\rollbar\helpers\IgnoreExceptionHelper::checkIgnore($toLog, [
                       ['yii\web\HttpException', 'statusCode' => [400, 404]],
                       ['yii\db\Exception', 'getCode' => [2002]],
                   ]
                );
            }
        ]
    ],
],

About

Rollbar integration for yii2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages