最近使用composer安裝時發(fā)現(xiàn)提示php的版本不匹配。執(zhí)行composer install遇到錯誤:Your requirements could not be resolved to an installable set of packages. 這是因為不匹配composer.json要求的版本。
完整錯誤如下:
[PHP]
vagrant@homestead:/usr/share/nginx/html/laravel-1$ 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
再次執(zhí)行composer命令可以正常安裝包了。