Closed sgtlambda closed 8 years ago
Same problem here, i think you are always welcome to submit a PR :)
Will change this behaviour.
Check v1.5.0
Still getting this error when I run php artisan migrate:refresh
.
PHP Fatal error: Uncaught InvalidArgumentException: Rollbar access token not configured in /var/www/vendor/jenssegers/rollbar/src/RollbarServiceProvider.php:67
Using latest version of laravel-rollbar v1.5.1
Using laravel v5.1.45
Here's my code in AppServiceProvider
:
public function boot()
{
if ($this->app->environment('production') && !empty(env('ROLLBAR_TOKEN'))) {
$this->app->register(RollbarServiceProvider::class);
}
}
The weird thing is I'm getting this exception when I'm on my local environment where I don't want to run Rollbar. In the .env file I have those 2 variables:
ROLLBAR_TOKEN=
ROLLBAR_LEVEL=debug
And here's app/services.php
file:
'rollbar' => [
'access_token' => env('ROLLBAR_TOKEN', ''),
'level' => env('ROLLBAR_LEVEL', 'error'),
],
I have the same problem. My APP_ENV is set to local and I dont want to configure Rollbar in local.
https://github.com/jenssegers/laravel-rollbar/blob/master/src/RollbarServiceProvider.php#L49
Does not really go inside if condition because I have $this->app['config']->get('services.rollbar') not empty.
Can it be if (! getenv('ROLLBAR_TOKEN') and ! $this->app['config']->get('services.rollbar.access_token'))
Rollbar checks if the config value is empty, and throws the exception, so an empty string won't work. I set a default value of 'none' in my config/services file. That also means if you have ROLLBAR_TOKEN=
in your .env file, then it will set an empty string as the value, and the exception will be thrown.
'rollbar' => [
'access_token' => env('ROLLBAR_TOKEN', 'none'),
'level' => env('ROLLBAR_LEVEL', 'error'),
]
It might be a good idea if this package is updated to let an empty string pass through without throwing an exception, and throw the exception when the user attempts to use the logger. There are going to be valid situations where an empty string is going to be set as the config value, so the package should account for it without breaking artisan.
Unfortunately setting the TOKEN
to none
as suggested above no longer seems to work:
'access_token' must be 32 characters long, was 'none'
My deployment script packages the build in a separate directory where the
.env
file is not present (and thus the access token is empty). Whenphp artisan clear-compiled
is ran, the build halts with the following error:For the sake of context, I have my
services.php
configured as follows:I think a solution would be to make the access_token an optional configuration parameter, in such a way that the rollbar log handler simply does not register if it is not set. Am I welcome to submit a PR?