Composer 设置忽略版本匹配的方法

简介

Composer是PHP中用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer会帮你安装这些依赖的库文件。接下来通过本文给大家介绍Composer设置忽略版本匹配的方法,需要的朋友参考下吧

执行composer install遇到错误:Your requirements could not be resolved to an installable set of packages. 这是因为不匹配composer.json要求的版本。

完整错误

vagrant@homestead:/usr/share/nginx/html/laravel-blog$ sudo composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for doctrine/instantiator 1.0.3 -> satisfiable by doctrine/instantiator[1.0.3].
- doctrine/instantiator 1.0.3 requires php ~5.3 -> your PHP version (7.0.3) does not satisfy that requirement.
Problem 2
- doctrine/instantiator 1.0.3 requires php ~5.3 -> your PHP version (7.0.3) does not satisfy that requirement.
- phpunit/phpunit-mock-objects 2.3.0 requires doctrine/instantiator ~1.0,>=1.0.1 -> satisfiable by doctrine/instantiator[1.0.3].
- Installation request for phpunit/phpunit-mock-objects 2.3.0 -> satisfiable by phpunit/phpunit-mock-objects[2.3.0].

提示我的PHP 7版本太高,不符合composer.json需要的版本,但是在PHP 7下应该也是可以运行的,composer可以设置忽略版本匹配,命令是:

解决方案

composer install --ignore-platform-reqs

or

composer update --ignore-platform-reqs

再次执行composer命令可以正常安装包了。

重改转载自 : https://www.jb51.net/article/83133.htm

最后修改:3年前
如果觉得我的文章对你有用,请随意赞赏

共有 0 条评论