gpt4 book ai didi

php - Laravel 4.2 - Composer 更新问题

转载 作者:可可西里 更新时间:2023-11-01 13:31:45 26 4
gpt4 key购买 nike

在处理 Laravel 项目之前,我尝试像往常一样运行 composer install 和 composer update。但是我遇到了一个奇怪的问题,我似乎已经有一段时间无法解决了。

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

在谷歌搜索这个问题后,我尝试了以下解决方案,但都没有奏效:

  1. 删除 vendor 文件夹和 composer.lock,然后运行 ​​composer install
  2. 删除 bootstrap/compiled.php 然后运行 ​​composer update
  3. 运行php artisan cache:clearphp artisan views:clear 清空storage/views 目录。 php artisan 也不行
  4. 我尝试手动删除 storage/views 但也失败了
  5. Composer 更新 --no-scripts。

我将文件夹的权限更改为 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"
}

更新:

所以我一直跟踪从 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这里')enar 也遵循同样的问题。第一个 foreach 循环一直显示 Invalid argument supplied for foreach,这很奇怪,因为我不能使用 php artisan 来迁移数据库,甚至播种它。

更奇怪的是,相同的代码目前正在运行并正常工作。

知道这里的问题是什么吗?!

最佳答案

您是否尝试过 sudo composer 安装/更新?我今天遇到了类似的问题并用 sudo 修复了它

关于php - Laravel 4.2 - Composer 更新问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36627429/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com