Composer PHP version错误解决方法

程序引用了Composer包,页面报错如下:

Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".

检查以下路径文件:

/vendor/composer/platform_check.php

发现如下检测PHP版本的代码:

if (!(PHP_VERSION_ID >= 80100)) {
	$issues[] = 'Your Composer dependencies require a PHP version ">= 8.1.0". You are running ' . PHP_VERSION . '.';
}

本地电脑PHP版本正是8.1.0,因此考虑安装Composer包时忽略PHP版本检测:

composer install 包名称 --ignore-platform-reqs

更新包使用:

composer update 包名称 --ignore-platform-reqs

以阿里云短信服务SDK为例:

composer require alibabacloud/dysmsapi-20170525 2.0.24 --ignore-platform-reqs
阿里云