Laravel:array_merge():参数 #2 不是数组错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25575217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 16:42:45  来源:igfitidea点击:

Laravel: array_merge(): Argument #2 is not an array error

laravellaravel-4composer-php

提问by Deepak Thomas

Exceptions started to appear in all views, and when I try to run composer update, it always ends up with

异常开始出现在所有视图中,当我尝试运行时composer update,它总是以

{"error":{"type":"ErrorException","message":"array_merge(): Argument #2 is not an array","file":"\/laravel\/framework\/src\/Illuminate\/Foundation\/ProviderRepository.php","line":188}}

回答by Deepak Thomas

After a lot of searching and exploring each file in the 'app' folder, it appears that one file was corrupt

经过大量搜索和探索“app”文件夹中的每个文件后,似乎有一个文件已损坏

Deleteapp/storage/meta/services.jsonand re-run composer updateand this should solve it.

删除app/storage/meta/ services.json并重新运行composer update,这应该可以解决它。

回答by Tahsin Abrar

Sometimes only deleting app/storage/meta/services.jsonand run composer updatedoesn't solve the ERROR: array_merge(): Argument #2 is not an array error. At least in my case, it didn't.

有时仅删除app/storage/meta/services.json并运行composer update并不能解决 ERROR: array_merge(): Argument #2 is not an array error。至少在我的情况下,它没有。

Most of the time it happens when you're screwing up the bootstrap/cache/services.jsonfile. And running composer updatewill not generate services.jsonfile.

大多数情况下,当您搞砸bootstrap/cache/services.json文件时会发生这种情况。并且运行composer update不会生成services.json文件。

To generate the services.jsonfile, you need to delete the previous bootstrap/cache/services.jsonfile and run php artisan serve. Then it'll generate a fresh services.json` file.

要生成该services.json文件,您需要删除以前的bootstrap/cache/services.json文件并运行php artisan serve. 然后它会生成一个新的 services.json` 文件。

Hope it helps to someone!

希望它对某人有所帮助!

回答by fico7489

  1. delete bootstrap folder
  2. git reset --hard
  3. composer install
  4. done
  1. 删除引导文件夹
  2. git reset --hard
  3. 作曲家安装
  4. 完毕

回答by Andy

I had similar problem with a fresh install.

我在全新安装时遇到了类似的问题。

I solved it like this: Removed bootsrap/cache/**services.php**and then i surfed to the website with browser, it generated a new services.php and then it worked.

我是这样解决的:删除bootsrap/cache/**services.php**然后我用浏览器浏览网站,它生成了一个新的 services.php 然后它工作了。

回答by Sad?k Menduh A?ar

I solved it:

我解决了:

open This folder-->/Applications/MAMP/htdocs/*****/vendor/laravel/framework/src/Illuminate/View/Factory.php

打开这个文件夹-->/Applications/MAMP/htdocs/*****/vendor/laravel/framework/src/Illuminate/View/Factory.php

and comment this line

并评论这一行

//$data = array_merge($mergeData, $this->parseData($data));

line number -> 136.

行号 -> 136。

回答by Alex Celmer

You probably just forgot to put compact('var') as the second return view argument

您可能只是忘记将 compact('var') 作为第二个返回视图参数

return view("path.to.view", compact ('var'))

返回视图(“path.to.view”,紧凑('var')

回答by Ariful Haque

Just a composer updateworked for me.

只是composer update对我有用。