You can install the package via composer:
composer require soyhuce/laravel-rollbar
You can then add rollbar configuration in your config/logging.php
return [
//...
'channels' => [
'rollbar' => [
'driver' => 'monolog',
'handler' => \Soyhuce\LaravelRollbar\LaravelRollbarHandler::class,
'level' => env('LOG_LEVEL', 'error'),
'access_token' => env('ROLLBAR_SERVER_KEY'),
],
],
];
You can add the configurations you need. See the Rollbar documentation for more information.
You can customize the current user resolution
with \Soyhuce\LaravelRollbar\Facades\Rollbar::resolveAuthenticatedUserUsing()
. You may want to add this in a service
provider (for example AppServiceProvider
).
\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,
];
});
A default user resolver is provided in this package.
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.