错误内容
vagrant@homestead:/usr/share/nginx/html/laravel-blog$ sudocomposerinstall
Loadingcomposerrepositorieswithpackage information
Installingdependencies (includingrequire-dev) fromlockfile
Yourrequirementscouldnot beresolvedto aninstallablesetofpackages.
Problem 1
- Installationrequestfor doctrine/instantiator 1.0.3 -> satisfiablebydoctrine/instantiator[1.0.3].
- doctrine/instantiator 1.0.3 requiresphp ~5.3 -> yourPHPversion (7.0.3) doesnot satisfythatrequirement.
Problem 2
- doctrine/instantiator 1.0.3 requiresphp ~5.3 -> yourPHPversion (7.0.3) doesnot satisfythatrequirement.
- phpunit/phpunit-mock-objects 2.3.0 requiresdoctrine/instantiator ~1.0,>=1.0.1 -> satisfiablebydoctrine/instantiator[1.0.3].
- Installationrequestfor phpunit/phpunit-mock-objects 2.3.0 -> satisfiablebyphpunit/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命令,就可以正常运行了
特殊情况
当前我使用的镜像,设置的是阿里云镜像。
拉取新项目后,更新失败后,通过以上方式进行解决问题。
操作依旧失败,错误内容如下:
执行添加
E:\phpstudy_pro\WWW\yuxiang-php>composer install --ignore-platform-reqs
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires topthink/framework, it could not be found in any version, there may be a typo in the package name.
Problem 2
- Root composer.json requires topthink/think-image, it could not be found in any version, there may be a typo in the package name.
Problem 3
- Root composer.json requires topthink/think-captcha, it could not be found in any version, there may be a typo in the package name.
执行更新
E:\phpstudy_pro\WWW\yuxiang-php>composer update --ignore-platform-reqs
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires topthink/framework, it could not be found in any version, there may be a typo in the package name.
Problem 2
- Root composer.json requires topthink/think-image, it could not be found in any version, there may be a typo in the package name.
解决办法
重新核对项目程序后,拿去其他项目composer.json进行更新,可以正常更新。
比较其他项目composer.json与新项目的composer.json进行对比
发现新项目的composer.json下多出已下内容,删除后,重新更新,正常拉取内容。
"repositories": {
"packagist": {
"type": "composer",
"url": "https://packagist.phpcomposer.com"
}
}
查询相关composer配置后,发现这里设置的是国内镜像。
重新设置本地composer源地址为以上国内镜像,重新测试,发现问题依旧。
删除上面部分内容,更新正常。