Laravel 4.2 - 作曲家更新问题
问题描述:
我尝试在使用Laravel项目之前像往常一样运行作曲家安装和作曲家更新。但是,我遇到了一个我似乎无法解决的奇怪问题。Laravel 4.2 - 作曲家更新问题
PHP Fatal error: Uncaught exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7:35
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7(35): Illuminate\Exception\Handler->handleError(2, 'Invalid argumen...', '/Applications/X...', 35, Array)
#1 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(35): include('/Applications/X...')
#2 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(56): Illuminate\View\Engines\PhpEngine->evaluatePath('/Applications/X...', Array)
#3 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/framework/src/Illuminate/View/View.php(134): Illuminate\View\Engines\CompilerEngine->get('/Applications/X...', Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/ in /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7 on line 35
PHP Fatal error: Uncaught exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7:35
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7(35): Illuminate\Exception\Handler->handleError(2, 'Invalid argumen...', '/Applications/X...', 35, Array)
#1 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(35): include('/Applications/X...')
#2 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(56): Illuminate\View\Engines\PhpEngine->evaluatePath('/Applications/X...', Array)
#3 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/framework/src/Illuminate/View/View.php(134): Illuminate\View\Engines\CompilerEngine->get('/Applications/X...', Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/ in /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7 on line 35
Script php artisan clear-compiled handling the post-update-cmd event returned with an error
[RuntimeException]
Error Output: PHP Fatal error: Uncaught exception 'ErrorException' with me
ssage 'Invalid argument supplied for foreach()' in /Applications/XAMPP/xamp
pfiles/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de
3dc7:35
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d
4682a7a7da163c9444d69f6b6de3dc7(35): Illuminate\Exception\Handler->handleEr
ror(2, 'Invalid argumen...', '/Applications/X...', 35, Array)
#1 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/fram
ework/src/Illuminate/View/Engines/PhpEngine.php(35): include('/Applications
/X...')
#2 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/fram
ework/src/Illuminate/View/Engines/CompilerEngine.php(56): Illuminate\View\E
ngines\PhpEngine->evaluatePath('/Applications/X...', Array)
#3 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/fram
ework/src/Illuminate/View/View.php(134): Illuminate\View\Engines\CompilerEn
gine->get('/Applications/X...', Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/ in /Applications/XAMPP/xamppfiles
/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7 o
n line 35
PHP Fatal error: Uncaught exception 'ErrorException' with message 'Invalid
argument supplied for foreach()' in /Applications/XAMPP/xamppfiles/htdocs/
wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7:35
Stack trace:
#0 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/app/storage/views/d
4682a7a7da163c9444d69f6b6de3dc7(35): Illuminate\Exception\Handler->handleEr
ror(2, 'Invalid argumen...', '/Applications/X...', 35, Array)
#1 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/fram
ework/src/Illuminate/View/Engines/PhpEngine.php(35): include('/Applications
/X...')
#2 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/fram
ework/src/Illuminate/View/Engines/CompilerEngine.php(56): Illuminate\View\E
ngines\PhpEngine->evaluatePath('/Applications/X...', Array)
#3 /Applications/XAMPP/xamppfiles/htdocs/wild-guanabana/vendor/laravel/fram
ework/src/Illuminate/View/View.php(134): Illuminate\View\Engines\CompilerEn
gine->get('/Applications/X...', Array)
#4 /Applications/XAMPP/xamppfiles/htdocs/ in /Applications/XAMPP/xamppfiles
/htdocs/wild-guanabana/app/storage/views/d4682a7a7da163c9444d69f6b6de3dc7 o
n line 35
谷歌搜索这个问题之后,我尝试以下解决方案,但没有一次成功:
- 去除
vendor
文件夹和composer.lock
,然后运行composer install
- 去除
bootstrap/compiled.php
,然后运行composer update
- 运行
php artisan cache:clear
或php artisan views:clear
清空storage/views
目录。php artisan
也不起作用 - 我试着手动删除
storage/views
,但它也失败 - 作曲家更新 - 无脚本。
我更改文件夹的权限为777
,以防万一它是一个权限问题,但它也失败了。
这里的composer.json以防万一:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.2.7"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable"
}
UPDATE:
所以我一直跟踪我从storage/views
收到错误找到它在第一foreach
循环:
<div class="sub-menu">
@foreach($_destinationsList as $destination)
<ul>
<li>
<a href="{{_url('destination/'.$destination->slug)}}">{{$destination->{_en('name')._ar('name_ar')} }}</a>
</li>
@foreach($destination->children as $destination)
<li>
<a href="{{_url('destination/'.$destination->slug)}}">{{$destination->{_en('name')._ar('name_ar')} }}</a>
</li>
@endforeach
</ul>
@endforeach
</div>
此外,我发现url
函数前面有_
,据我记得Laravel 4.2不在那里,你只写url('url here')
。 en
和ar
也遵循相同的问题。第一个foreach
循环继续声明Invalid argument supplied for foreach
,这很奇怪,因为我不能使用php artisan
来迁移数据库或甚至为它创建种子。
更奇怪的是,相同的代码目前正常工作并正常工作。
任何想法可能是这里的问题?!
答
虽然这很奇怪,但我发现错误。数据库配置中的host
被设置为localhost
,并且由于某些未知原因,它无法正常工作并出现上述错误。我将它更改为127.0.0.1
,它正常工作。
我找不出真正的原因,因为在错误追踪中没有任何与此部分相关的原因。
您是否尝试手动删除app/storage/views中的所有内容? – aynber
@aynber是的,我做过 – omarsafwany
如果你在你的IDE中打开一个项目,你是否碰巧看到下划线,就像项目文件夹堆栈中的错误一样? – Norgul