wire-elements / spotlight

Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
MIT License
911 stars 71 forks source link

"Invalid argument supplied for foreach()" on composer require #13

Closed adddz closed 3 years ago

adddz commented 3 years ago

Amazing package, first of all! 👏

I've tried installing the package in a fresh new Laravel project and it works fine. The issue is with an existing Laravel project, composer require returns this error. Any ideas? Thank you!

ErrorException 

  Invalid argument supplied for foreach()

  at vendor/livewire-ui/spotlight/src/SpotlightServiceProvider.php:35
     31▕                 $view->cssPath = __DIR__ . '/../public/spotlight.css';
     32▕             }
     33▕         });
     34▕ 
  ➜  35▕         foreach (config('livewire-ui-spotlight.commands') as $command) {
     36▕             Spotlight::registerCommand($command);
     37▕         }
     38▕     }
     39▕ }

      +9 vendor frames 
  10  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(LivewireUI\Spotlight\SpotlightServiceProvider))
adddz commented 3 years ago

Found the solution. For anybody having this issue, it's related to the config cache. Remove the package, run php artisan config:clear and install the package again.