PHP code example of baibaratsky / yii2-rollbar

1. Go to this page and download the library: Download baibaratsky/yii2-rollbar library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

baibaratsky / yii2-rollbar example snippets


 'bootstrap' => ['rollbar'],
 'components' => [
     'rollbar' => [
         'class' => 'baibaratsky\yii\rollbar\Rollbar',
         'accessToken' => 'POST_SERVER_ITEM_ACCESS_TOKEN',
         
         // You can specify exceptions to be ignored by yii2-rollbar:
         // 'ignoreExceptions' => [
         //         ['yii\web\HttpException', 'statusCode' => [400, 404]],
         //         ['yii\web\HttpException', 'statusCode' => [403], 'message' => ['This action is forbidden']],
         // ],
     ],
 ],
 

 'components' => [
     'errorHandler' => [
         'class' => 'baibaratsky\yii\rollbar\web\ErrorHandler',
         
         // You can    //         'exceptionCode' => $errorHandler->exception->getCode(),
         //         'rawRequestBody' => Yii::$app->request->getRawBody(),
         //     ];
         // },
     ],
 ],
 

 'components' => [
     'errorHandler' => [
         'class' => 'baibaratsky\yii\rollbar\console\ErrorHandler',
     ],
 ],
 

 use baibaratsky\yii\rollbar\WithPayload;
 
 class SomeException extends \Exception implements WithPayload
 {
     public function rollbarPayload()
     {
         return ['foo' => 'bar'];
     }
 }
 

 'log' => [
     'targets' => [
         [
             'class' => 'baibaratsky\yii\rollbar\log\Target',
             'levels' => ['error', 'warning', 'info'], // Log levels you want to appear in Rollbar
             
             // It is highly recommended that you specify certain categories.
             // Otherwise, the exceptions and errors handled by the error handlers will be duplicated.
             'categories' => ['application'],
         ],
     ],
 ],
 

 $ php composer.phar