soyhuce / laravel-rollbar
Rollbar wrapper for Laravel
0.1.1
2022-01-07 14:55 UTC
Requires
- php: ^8.0
- illuminate/contracts: ^8.74 || ^9.0
- illuminate/support: ^8.74 || ^9.0
- rollbar/rollbar: ^3.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- orchestra/testbench: ^6.23 || ^7.0
- pestphp/pest: ^1.21
- phpunit/phpunit: ^9.5
README
Rollbar wrapper for Laravel
Installation
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.
Customizing current user resolution
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.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.