[英]How to downgrade PHP version (Your PHP version does not satisfy that requirement)?
After running sudo apt-get update && sudo apt-get dist-upgrade
on my Laravel app, I'm getting this error on the next deployment:在我的 Laravel 应用程序上运行
sudo apt-get update && sudo apt-get dist-upgrade
后,我在下一次部署时收到此错误:
- This package requires php ^7.1.3 but your PHP version (8.1.6) does not satisfy that requirement.
In my composer.json, ^7.1.3 is the specified version.在我的 composer.json 中,^7.1.3 是指定的版本。 This is my first time running the apt-get update and I don't know why the php version got updated as well.
这是我第一次运行 apt-get 更新,我不知道为什么 php 版本也会更新。
On each deployment I run在我运行的每个部署中
composer install --no-interaction --prefer-dist --optimize-autoloader
How can I downgrade the version to 7.1.3 ?
如何将版本降级到7.1.3 ? This happens on an existing app in production and I have to be very careful about it.
这发生在生产中的现有应用程序上,我必须非常小心。
The php version installed on your environment should be compatible with your project.您的环境中安装的 php 版本应该与您的项目兼容。
If your project is based on composer package manager (as I see), it can help you to control which php version you need on the server.如果您的项目基于 composer package 管理器(如我所见),它可以帮助您控制服务器上需要哪个 php 版本。
In your case I would recommend to restore from the snapshot or just install php 7.1.3 version back.在您的情况下,我建议从快照中恢复或只安装 php 7.1.3 版本。
If you want to use php 7.4/8/8.1 in your project, before you should upgrade your code and project dependencies and ensure, that everything working fine with the desired version of php.如果您想在您的项目中使用 php 7.4/8/8.1,在升级您的代码和项目依赖项之前,请确保一切都与所需版本的 php 一起正常工作。
Old topic, but for things like this, I recommend adding the flag to ignore requirements like this.老话题,但是对于这样的事情,我建议添加标志来忽略这样的要求。 So try:
所以试试:
composer install --no-interaction --prefer-dist --optimize-autoloader --ignore-platform-reqs
There may be incompatibilities with your project using 8.1 instead of 7.1.3, but I doubt it.使用 8.1 而不是 7.1.3 可能与您的项目不兼容,但我对此表示怀疑。 But still, only do this if you feel confident the PHP version won't be an issue.
但是,只有当您确信 PHP 版本不会成为问题时,才这样做。 It's usually better than downgrading, however.
但是,这通常比降级要好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.