简体   繁体   English

Laravel 8 是否需要 PHP 8.1?

[英]Does Laravel 8 require PHP 8.1?

So.. I developed a project with Laravel 9 , then I had to upload it to my client's server by FTP ( which was slow and painful ) to find out only afterwards that my client's server PHP version could not go over 8.0.所以.. 我用Laravel 9开发了一个项目,然后我不得不通过 FTP 将它上传到我客户的服务器(这很慢而且很痛苦)之后才发现我客户的服务器 PHP 版本不能超过 8.0。 I tried to open the project live link ( to where I uploaded ) and the composer platform check was telling me my project had dependencies on PHP 8.1 and that my version is 8.0.我试图打开项目实时链接(指向我上传的位置),作曲家平台检查告诉我我的项目依赖于 PHP 8.1,而我的版本是 8.0。

So I tried tweaking the platform check php file to disable this check, to see if it would work anyways but no, the project was throwing errors.因此,我尝试调整平台检查 php 文件以禁用此检查,以查看它是否仍能正常工作,但没有,该项目正在抛出错误。

So I decided to downgrade to laravel 8 , because after searching around I read that laravel 8 did not need php 8.1.所以我决定降级到 laravel 8 ,因为在四处搜索后我读到 laravel 8 不需要 php 8.1。 I guess I read some wrong information because after tweaking my project to downgrade to laravel 8 and uploading again (painfully by ftp), the platform check was again telling me that my project needed PHP 8.1.我想我读到了一些错误的信息,因为在调整我的项目以降级到 laravel 8 并再次上传(通过 ftp 痛苦地)之后,平台检查再次告诉我我的项目需要 PHP 8.1。

So I disabled again this platform check by editing/tweaking the platform check php file, to see if it would work anyway, and it did work.所以我通过编辑/调整平台检查 php 文件再次禁用了这个平台检查,看看它是否能正常工作,它确实有效。 So all good.所以一切都很好。 but then today I was learning how to check which composer packages had dependencies on a specific php version, and in the process I found out (if I'm not wrong) that laravel 8 has package dependencies that depend on PHP 8.1?但是今天我正在学习如何检查哪些作曲家包依赖于特定的 php 版本,并且在这个过程中我发现(如果我没记错的话) laravel 8 具有依赖于 PHP 8.1 的包依赖性?

Is there a table somewhere I can check which Laravel versions depend on which PHP versions or do I have to run some commands on each project to check these dependencies?有什么地方可以检查哪些 Laravel 版本依赖于哪些 PHP 版本,还是我必须在每个项目上运行一些命令来检查这些依赖关系?

Like in the images below:如下图所示:

laravel 包依赖 php 8.1

Thanks !谢谢 !

Laravel 9 does not require PHP 8.1 it requires PHP 8.0.2 Laravel 9 不需要 PHP 8.1 它需要 PHP 8.0.2

If this a shared project and someone else with PHP 8.1 generated the composer.lock file (or indeed you locally have PHP 8.1 but the server has 8.0) you might end up with packages that require PHP 8.1.如果这是一个共享项目,而其他人使用 PHP 8.1 生成了composer.lock文件(或者实际上您本地有 PHP 8.1 但服务器有 8.0),您最终可能会得到需要 Z2FEC3922204A5C23ACZ138 的软件包。 Composer resolves and installs packages based on the locally installed PHP version. Composer 根据本地安装的 PHP 版本解析和安装包。

You can override this behaviour and ensure everyone gets package deps based on the PHP version you expect to have on production if you use the platform config option in your composer.json eg add this to your composer.json You can override this behaviour and ensure everyone gets package deps based on the PHP version you expect to have on production if you use the platform config option in your composer.json eg add this to your composer.json

"config": {
  "platform": {
     "php": "8.0.2" 
  }
}

Then run然后运行

composer update

this should try to fix your package versions to ones that work with PHP 8这应该尝试将您的 package 版本修复为与 PHP 8 一起使用的版本

Short response no, Laravel 8 requires PHP >= 7.3 From Server Requirements But, since you downgraded it is possible that some php packages require newer php versions no matter the version chosen for Laravel. Short response no, Laravel 8 requires PHP >= 7.3 From Server Requirements But, since you downgraded it is possible that some php packages require newer php versions no matter the version chosen for Laravel.

Some hints:一些提示:

  • Change dependencies (packages) version, probably downgrade them.更改依赖项(包)版本,可能会降级它们。
  • Delete the vendor folder.删除供应商文件夹。
  • Delete composer.lock删除 composer.lock
  • Run composer install运行作曲家安装

Checking your screenshot: with symfony the downgrade will not break anything.检查您的屏幕截图:使用 symfony 降级不会破坏任何东西。 But, check the other package/s ie: tojsverkoyen/css-to-inline-styles requirements.但是,请检查其他包,即:tojsverkoyen/css-to-inline-styles 要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM