使用 Composer 在 Laravel 5.x 中安装 Google 的 ClientAPI

install Google's ClientAPI in Laravel 5.x with Composer

我一直在尝试安装 Google 的 ClientAPI,但它有很多依赖性问题。我在网上搜索过,没有任何运气。

我尝试自己安装错误的依赖项,但他们有同样的问题。这是我收到的消息:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - google/apiclient v2.0.0-RC3 requires guzzlehttp/guzzle 5.2.* -> satisfiable by guzzlehttp/guzzle[5.2.0] but these conflict with your requirements or minimum-stability.
    - google/apiclient v2.0.0-RC2 requires guzzlehttp/guzzle 5.2.* -> satisfiable by guzzlehttp/guzzle[5.2.0] but these conflict with your requirements or minimum-stability.
    - google/apiclient v2.0.0-RC1 requires guzzlehttp/guzzle 5.2.* -> satisfiable by guzzlehttp/guzzle[5.2.0] but these conflict with your requirements or minimum-stability.
    - Conclusion: don't install google/apiclient 2.x-dev
    - Conclusion: don't install google/apiclient v2.0.3
    - Installation request for phpseclib/phpseclib (locked at 0.3.10) -> satisfiable by phpseclib/phpseclib[0.3.10].
    - Conclusion: don't install google/apiclient v2.0.2
    - Conclusion: don't install google/apiclient v2.0.1
    - google/apiclient v2.0.0 requires google/auth 0.8 -> satisfiable by google/auth[v0.8].
    - google/apiclient v2.0.0-RC8 requires google/auth 0.8 -> satisfiable by google/auth[v0.8].
    - Conclusion: don't install google/auth v0.8
    - Installation request for guzzlehttp/psr7 (locked at 1.4.x-dev) -> satisfiable by guzzlehttp/psr7[1.4.x-dev].
    - google/apiclient v2.0.0-RC6 requires google/auth 0.7 -> satisfiable by google/auth[v0.7].
    - google/apiclient v2.0.0-RC7 requires google/auth 0.7 -> satisfiable by google/auth[v0.7].
    - Conclusion: don't install google/auth v0.7
    - google/apiclient v2.0.0-RC4 requires google/auth 0.5 -> satisfiable by google/auth[v0.5].
    - google/apiclient v2.0.0-RC5 requires google/auth 0.5 -> satisfiable by google/auth[v0.5].
    - Conclusion: don't install google/auth v0.5
    - Installation request for google/apiclient ^2.0 -> satisfiable by google/apiclient[2.x-dev, v2.0.0, v2.0.0-RC1, v2.0.0-RC2, v2.0.0-RC3, v2.0.0-RC4, v2.0.0-RC5, v2.0.0-RC6, v2.0.0-RC7, v2.0.0-RC8, v2.0.1, v2.0.2, v2.0.3].


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

此时我能想到的就是在composer之外安装ClientAPI,但我不知道这是否是个好主意!

这是我的 composer.json 文件(只有相关部分):

"minimum-stability": "dev",
"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "tymon/jwt-auth": "0.5.*",
    "barryvdh/laravel-cors": "^0.8.0",
    "laravel/socialite": "^2.0",
    "guzzlehttp/guzzle": "^6.1",
    "intervention/image": "^2.3",
    "kozz/laravel-guzzle-provider": "^6.0",
    "symfony/psr-http-message-bridge": "^0.2.0",
    "fairholm/elasticquent": "dev-feature/laravel-5",
    "graham-campbell/flysystem": "^3.3",
    "league/flysystem-sftp": "^1.0",
    "netshell/paypal": "dev-master",
    "facebook/php-sdk-v4": "~5.0"
},

问题是您的旧包要求与新包要求之间存在冲突。

这是作曲家最糟糕的部分或作曲家的缺点。

您必须手动安装一个能同时满足这两个软件包的软件包版本。相信我,这很难做到。

Installation request for phpseclib/phpseclib (locked at 0.3.10)

Installation request for guzzlehttp/psr7 (locked at 1.4.x-dev)

似乎某些软件包“锁定”在特定版本(根据您的composer.lock)。

要了解它们被锁定的原因,运行:

composer why org/package -t

您可以尝试通过以下方式更新这些依赖项:

composer update --with-dependencies

但是,如果这样做没有帮助,请考虑删除 composer.lock 和 re-run composer install

也试试你在空文件夹上的配置。

要查看安装的依赖树,运行:

composer show -t

要查看给定包的要求,运行 例如:

composer show -a google/apiclient 2.0.3

这可以让我们知道哪里出了问题。要查看更详细的输出,请将 -v 添加到您的命令中。

要进一步解决问题,请参阅:

  • How to resolve a "Can only install one of:" conflict?

我在 GitHub google API PHP 客户端问题和讨论中找到了解决方案。这实际上也解决了我的问题。参考原文 post 这样它也可以节省一些人的时间。

https://github.com/googleapis/google-api-php-client/issues/969

想法是直接将 "google/apiclient": "^2.0" 添加到 composer.json 和 运行 composer update。