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.

6
  • 1
    Error says $config is not array Commented Dec 18, 2018 at 8:47
  • what is a $config?? Commented Dec 18, 2018 at 8:47
  • 1
    Show your service register method Commented Dec 18, 2018 at 8:52
  • Is this from laravel/framework/src/Illuminate/Support/ServiceProvider.php? Wouldn't change anything there. Check if all your config files are valid Commented Dec 18, 2018 at 8:53
  • yes it if from laravel/framework/src/Illuminate/Support/ServiceProvider.php Commented Dec 18, 2018 at 8:55

5 Answers 5

11

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

Sign up to request clarification or add additional context in comments.

2 Comments

this is the correct answer
this is crt answer. @Jignesh Joisar
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)

3 Comments

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.
It worked! thanks a lot, I had to generate a key after. But it worked!
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.
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.

Comments

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.

Comments

0

lists config/ you may have created empty an file in the config/ delete the empty image.php enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.