[英]Laravel - compact(): Undefined variable: operator in Builder.php
I have PHP version-7.3 installed in my system and Laravel-5.8.我的系统中安装了 PHP version-7.3 和 Laravel-5.8。 When I tried to rub composer install or composer update on an old Project with Laravel-5.4 and PHP Version-5.6.4, I got this error shown below:当我尝试在 Laravel-5.4 和 PHP Version-5.6.4 的旧项目上安装 composer install 或 composer update 时,出现如下错误:
In Builder.php line 1229: compact(): Undefined variable: operator Script php artisan optimize handling the post-install-cmd event returned with error code 1在 Builder.php 行 1229: compact(): Undefined variable: operator Script php artisan optimize handling the post-install-cmd event returned with error code 1
Then, when I tried to run the application, I got this error page as shown on the screen:然后,当我尝试运行该应用程序时,出现了如下屏幕所示的错误页面:
I tried to run:我试着跑:
php artisan cache:clear php 工匠缓存:清除
and和
composer update作曲家更新
but the problem is still there.但问题仍然存在。
How do I get it resolved?我该如何解决?
Thank you.谢谢你。
It looks like this issue was fixed in Laravel 5.5 according to this post: https://github.com/laravel/framework/issues/26936#issuecomment-449479336根据这篇文章,这个问题似乎在 Laravel 5.5 中得到修复: https://github.com/laravel/framework/issues/26936#issuecomment-449479336
Since Laravel 5.4 is no longer supported, your best option might be to upgrade.由于不再支持 Laravel 5.4,因此您最好的选择可能是升级。 You can find a list of the currently supported versions here: https://laravel.com/docs/releases您可以在此处找到当前支持的版本列表: https://laravel.com/docs/releases
The minimal upgrade that should still fix the error would be 5.4 to 5.5.仍应修复错误的最小升级将是 5.4 到 5.5。 The instructions can be found here: https://laravel.com/docs/5.5/upgrade#upgrade-5.5.0 (please note that support for 5.5 has also ended, but it might still fix your bug).可以在此处找到说明: https://laravel.com/docs/5.5/upgrade#upgrade-5.5.0 (请注意,对 5.5 的支持也已结束,但它可能仍会修复您的错误)。 This would also require you to switch the project to PHP 7.0.0 or greater.这还需要您将项目切换到 PHP 7.0.0 或更高版本。
If:如果:
explicitly define the PHP version on the Homestead.yaml file.在 Homestead.yaml 文件中明确定义 PHP 版本。 This should be done on the sites property as such (each is a new line, of course):这应该在 sites 属性上完成(当然,每个都是一个新行):
map: test.appp
/home/vagrant/code/test/public
php: "7.1"
map: test.appp
/home/vagrant/code/test/public
php: "7.1"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.