Laravel service provider: config is null
rolfdenhartog opened this issue ยท 7 comments
Maybe I'm the only one ๐ (I hope so). But when running the composer dump
command, it fails because there seems to be a bug in the register method of the service provider. I'm not using the config file in my own repo. So its using the config file from the packages. I'm using three .env
entries:
BUGSNAG_API_KEY=**********
BUGSNAG_BATCH_SENDING=true
BUGSNAG_NOTIFY_RELEASE_STAGES=test,production
Of course I'm trying to fix this. So I'm hoping to create a PR that will fix it. But until now no luck.
Steps to reproduce
- Install/Update Bugsnag on Laravel 9 project (in my case it is an upgrade of Laravel 8 to 9).
- Run
composer dump
Environment
- Bugsnag version: 2.23
- PHP version: 8.0
- Composer version: 2.2.6
- Laravel version: 9
Output of the terminal
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
ErrorException
Trying to access array offset on value of type null
at vendor/bugsnag/bugsnag-laravel/src/BugsnagServiceProvider.php:194
190โ public function register()
191โ {
192โ $this->app->singleton('bugsnag', function (Container $app) {
193โ $config = $app->config->get('bugsnag');
โ 194โ $client = new Client(new Configuration($config['api_key']), new LaravelResolver($app), $this->getGuzzle($config));
195โ
196โ $this->setupCallbacks($client, $app, $config);
197โ $this->setupPaths($client, $app, $config);
198โ
+10 vendor frames
11 app/Main/Exceptions/Handler.php:67
Illuminate\Support\Facades\Facade::__callStatic("notifyException")
+6 vendor frames
18 [internal]:0
Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}(Object(ErrorException))
Update 2022-09-02 15:32
This is running fine for a new installation of Laravel.
Somehow the issue has resolved ๐
I am facing a similar issue: Bugsnag\BugsnagLaravel\BugsnagServiceProvider::setupEvents(): Argument #2 ($config) must be of type array, null given, called in .../vendor/bugsnag/bugsnag-laravel/src/BugsnagServiceProvider.php on line 51 any help will be appreciated.
Did you try to clear the config (config:clear
)? And maybe deleting the PHP files in bootstrap/cache
might help? I don't remember what I did to fix it.
Having the same issue right now while deploying to AWS (through vapor), L194 as well. How did you guys fix this ?
Turns out it was an uppercase in the name of the config file of one of our own packages:
Myconfig.php => myconfig.php
Putting this here if it can help anyone in the future.
We're now hitting this, during an upgrade from laravel 10 to 11.
As @jbajou, above, we're getting the error when trying to deploy to Vapor on AWS.
In BugsnagServiceProvider.php line 260: Trying to access array offset on value of type null
The line number has changed but it's still the same piece of code.
259โ $config = $app->config->get('bugsnag');
โ 260โ $client = new Client(new Configuration($config['api_key']), new LaravelResolver($app), $this->getGuzzle($config));
- Bugsnag version: 2.28
- PHP version: 8.3
- Laravel version: 11
This is during a CI build in our github pipeline, so the config is clear and bootstrap/cache
contains no files.
This turned out to be an inconsistency with our build pipeline using php 8.3 but our dockerfile for vapor was still referencing php 8.1