baibaratsky / yii-rollbar
Rollbar Yii Extension
Installs: 29 544
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 2
Forks: 10
Open Issues: 2
Requires
- php: >=5.3
- rollbar/rollbar: ~1.3.1
README
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
-
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 yourcomposer.json
file. -
Add
rollbar
component to themain.php
config:// ... 'components' => array( // ... 'rollbar' => array( 'class' => 'application.vendor.baibaratsky.yii-rollbar.RollbarComponent', // adjust path if needed 'access_token' => 'your_serverside_rollbar_token', ), ),
-
Adjust
main.php
config to preload the component:'preload' => array('log', 'rollbar'),
-
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', ), ), ), ),