phplaravellaravel-5array-merge

Laravel array_merge(): Argument #2 is not an array In ServiceProvider.php


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.


Solution

  • 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)