【Composer】:Your requirements could not be resolved to an installable set of packages.

错误内容

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源地址为以上国内镜像,重新测试,发现问题依旧。
删除上面部分内容,更新正常。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值