[英]Laravel array_merge(): Argument #2 is not an array In ServiceProvider.php
我不能再做 php artisan serve 了,它说:
在 ServiceProvider.php 第 59 行:
array_merge(): Argument #2 is not an array
第59行代码在ServiceProvider.php中:
$this->app['config']->set($key, array_merge(require $path, $config));
我不明白我的 ServiceProvider.php 有什么问题,我没有改变任何东西。
我希望有人能帮助我。
检查config/
文件夹中的文件,其中一个没有返回数组。
试试这个
这里使用了is_array
方法。
$this->app['config']->set($key, array_merge(require $path, is_array($config) ? $config : [$config]))
is_array($config) ? $config : [$config]
如果不想更改框架文件,请检查配置文件夹中的
config
文件,其中一个文件返回单个值而不是数组(必须返回数组)
试试这个,
通过 Composer 对某些软件包进行的任何新安装都可能导致 vendor 下的文件发生冲突。
因此,通过“require”中的“composer.json”删除最后安装的包:{}并更新作曲家。
这对我有帮助。
这对我有用。 首先,编辑代码 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
));
}
保存。 并运行作曲家安装。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.