Composer Google API下载失败

时间:2018-03-13 11:12:19

标签: google-api composer-php

我尝试使用composer将google api下载到遗留代码,但是出现了以下错误:

composer require google/apiclient:^2.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for google/apiclient 2.0 -> satisfiable by google/apiclient[v2.0.0].
    - google/apiclient v2.0.0 requires google/auth 0.8 -> satisfiable by google/auth[v0.8].
    - Conclusion: don't install guzzlehttp/psr7 1.4.2
    - google/auth v0.8 requires guzzlehttp/psr7 1.2.* -> satisfiable by guzzlehttp/psr7[1.2.0, 1.2.1, 1.2.2, 1.2.3].
    - Can only install one of: guzzlehttp/psr7[1.2.0, 1.4.2].
    - Can only install one of: guzzlehttp/psr7[1.2.1, 1.4.2].
    - Can only install one of: guzzlehttp/psr7[1.2.2, 1.4.2].
    - Can only install one of: guzzlehttp/psr7[1.2.3, 1.4.2].
    - Installation request for guzzlehttp/psr7 (locked at 1.4.2) -> satisfiable by guzzlehttp/psr7[1.4.2].


Installation failed, reverting ./composer.json to its original content.

我该怎么办?

2 个答案:

答案 0 :(得分:0)

  

只能安装以下内容之一:guzzlehttp/psr7 [1.2.31.4.2]。

您的依赖项导致包的两个不同主要版本混淆,但只能安装一个。

locked at 1.4.2消息表示已根据您的composer.lock文件安装此软件包,并且您尝试安装与现有条件不兼容的不同版本。

$ composer show -a google/auth | grep psr7
guzzlehttp/psr7 ~1.2

您可以通过检查依赖关系树来检查哪个现有包依赖于锁定的版本:

composer show -t

在某些情况下,删除composer.lock可能有所帮助。

否则,要查看引用包的原因(从哪里),运行:

composer why guzzlehttp/psr7 -t

另请参阅:How to resolve a "Can only install one of:" conflict?

答案 1 :(得分:0)

尝试删除 vendor/google,然后再次运行 composer install,这对我有用。