4

I can not do php artisan serve anymore, it says :

In ServiceProvider.php line 59:

   array_merge(): Argument #2 is not an array

Line 59 code is in ServiceProvider.php:

$this->app['config']->set($key, array_merge(require $path, $config));

I dont understand what is wrong with my ServiceProvider.php, I did not change a thing there.

I hope some can help me.

Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
slekniws
  • 139
  • 1
  • 2
  • 6

4 Answers4

11

Check the files in your config/ folder, one of them is not returning an array.

naamhierzo
  • 345
  • 2
  • 8
4

try this one

used is_array method here.

$this->app['config']->set($key, array_merge(require $path, is_array($config) ? $config : [$config]))

is_array($config) ? $config : [$config]

if do not want change on framework file check configration files in your config folder one the file return single value not an array (must be return array)

Jignesh Joisar
  • 13,720
  • 5
  • 57
  • 57
  • 1
    Don't make any change in that file. The problem is surely somewhere else. Read the error message carefully, see the log and add the errors in your question. – Rouhollah Mazarei Dec 18 '18 at 08:59
  • It worked! thanks a lot, I had to generate a key after. But it worked! – slekniws Dec 18 '18 at 09:14
  • 1
    I recommend to _NOT_ edit the file `laravel/framework/src/Illuminate/Support/ServiceProvider.php`, this is a Laravel core file and might/will be overwritten on the next composer update - all your modifications will be lost. – brombeer Dec 18 '18 at 10:10
0

Try this,

Any new installation via Composer for some package may cause a conflict in file under vendor.

So remove the lastly installed package via "composer.json" in "require": { } and update the composer.

This helped me.

Shibu
  • 486
  • 1
  • 11
  • 20
0

This works for me. first, edit the code laravel/framework/src/Illuminate/Support/ServiceProvider.php

if (! ($this->app instanceof CachesConfiguration && $this->app->configurationIsCached())) {
        $config = $this->app->make('config');
        
        $configkey = $config->get($key, []);
        $configkey = is_array($configkey) ? $configkey : [$configkey];

        $config->set($key, array_merge(
            require $path, $configkey
        ));

    }

save it. and run composer install.

Abayomi Israel
  • 589
  • 6
  • 14