PHP code example of soyhuce / laravel-rollbar

1. Go to this page and download the library: Download soyhuce/laravel-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/ */

    

soyhuce / laravel-rollbar example snippets


return [
    //...

    'channels' => [
        'rollbar' => [
            'driver' => 'monolog',
            'handler' => \Soyhuce\LaravelRollbar\LaravelRollbarHandler::class,
            'level' => env('LOG_LEVEL', 'error'),
            'access_token' => env('ROLLBAR_SERVER_KEY'),
        ],
    ],
];

\Soyhuce\LaravelRollbar\Facades\Rollbar::resolveAuthenticatedUserUsing(function (): array {
    $user = auth()->user();
    
    if ($user === null) {
        return [];
    }
    
    return [
        'id' => (string) $user->id, // id must be a string
        'role' => $user->role->label,
    ];
});