php - Composer 无法安装 laravel/socialite 2.0

标签 php laravel composer-php laravel-socialite guzzle

Composer 需要 laravel/socialite ^2.0

因以下错误而失败:

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

  Problem 1
    - Installation request for laravel/socialite 2.0 -> satisfiable by laravel/socialite[v2.0.0].
    - Conclusion: remove guzzlehttp/guzzle 6.2.2
    - Conclusion: don't install guzzlehttp/guzzle 6.2.2
    - laravel/socialite v2.0.0 requires guzzlehttp/guzzle ~4.0 -> satisfiable by guzzlehttp/guzzle[4.0.0, 4.0.1, 4.0.2, 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.1.4, 4.1.5, 4.1.6, 4.1.7, 4.1.8, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4].
    - Can only install one of: guzzlehttp/guzzle[4.0.0, 6.2.2].
    ...
    - Can only install one of: guzzlehttp/guzzle[4.2.4, 6.2.2].
    - Installation request for guzzlehttp/guzzle (locked at 6.2.2) -> satisfiable by guzzlehttp/guzzle[6.2.2].


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

Laravel 版本是 5.3.22

PHP 版本为 7.0.10

composer.json of socialite2.0在 github 上将依赖项显示为 guzzlehttp 5.0/6.0。为什么我的安装寻找 guzzlehttp 4.0?

EDIT-1:

我试图通过在 composer.json require-dev 中添加它来强制 guzzlehttp 4.2.4。

但是,我收到以下错误:

  Problem 1
    - The requested package guzzlehttp/guzzle (locked at 6.2.2, required as 4.2.4) is satisfiable by guzzlehttp/guzzle[6.2.2] but these conflict with your requirements or minimum-stability.
  Problem 2
    - aws/aws-sdk-php 3.19.23 requires guzzlehttp/guzzle ^5.3.1|^6.2.1 -> satisfiable by guzzlehttp/guzzle[5.3.1, 5.3.2, 5.3.x-dev, 6.2.1, 6.2.2, 6.2.3, 6.3.0, 6.2.x-dev] but these conflict with your requirements or minimum-stability.
    - aws/aws-sdk-php 3.19.23 requires guzzlehttp/guzzle ^5.3.1|^6.2.1 -> satisfiable by guzzlehttp/guzzle[5.3.1, 5.3.2, 5.3.x-dev, 6.2.1, 6.2.2, 6.2.3, 6.3.0, 6.2.x-dev] but these conflict with your requirements or minimum-stability.
    - aws/aws-sdk-php 3.19.23 requires guzzlehttp/guzzle ^5.3.1|^6.2.1 -> satisfiable by guzzlehttp/guzzle[5.3.1, 5.3.2, 5.3.x-dev, 6.2.1, 6.2.2, 6.2.3, 6.3.0, 6.2.x-dev] but these conflict with your requirements or minimum-stability.
    - Installation request for aws/aws-sdk-php (locked at 3.19.23) -> satisfiable by aws/aws-sdk-php[3.19.23].

显然,aws-sdk-php 需要 guzzlehttp 5.3/6.2。 Laravel 5.3 与 socialite 3.0 不兼容。 Socialite 2.0 与 guzzlehttp 5.3/6.2 不兼容。

如何解决?

TIA

EDIT-2:

我的 composer.json 包含以下内容:

{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
    "php": ">=5.6.4",
    "laravel/framework": "5.3.*",
    "doctrine/dbal": "^2.5",
    "aws/aws-sdk-php-laravel": "~3.0"
},
"require-dev": {
    "fzaninotto/faker": "~1.4",
    "mockery/mockery": "0.9.*",
    "phpunit/phpunit": "~5.0",
    "symfony/css-selector": "3.1.*",
    "symfony/dom-crawler": "3.1.*"
},
"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "App\\": "app/"
    }
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php"
    ]
},
"scripts": {
    "post-root-package-install": [
        "php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ],
    "post-install-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postInstall",
        "php artisan optimize"
    ],
    "post-update-cmd": [
        "Illuminate\\Foundation\\ComposerScripts::postUpdate",
        "php artisan optimize"
    ]
},
"config": {
    "preferred-install": "dist"
}

最佳答案

问题是这样解决的:原来很简单。由于我仍在学习 composer 可以做什么,所以我之前无法弄清楚。

在版本中从 ^ 更改为 ~ 就成功了。根据 Mastering Composer - tips & tricks ,波浪号 (~) 和插入符 (^) 都应该允许包中的次要版本。但是,似乎“只注意中断更改”优先于允许次要版本。 (至少,这是我得出的结论)。

结果如下:

composer require laravel/socialite:~2.0
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing league/oauth1-client (1.7.0): Downloading (100%)
  - Installing laravel/socialite (v2.0.21): Downloading (100%)
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
Generating optimized class loader
Compiling common classes

关于php - Composer 无法安装 laravel/socialite 2.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48427357/

相关文章:

php - 创建菜单时将 url 包含在 mysql 字段中

php 重载 = 运算符

c# - 如何将事件从基于 Laravel 的服务器广播到基于 .net C# 的客户端?

php - Laravel Format AllDirectories() 输出到树中

php - 您的要求无法解析为一组可安装的软件包。 - 拉维尔 5.7

php - Laravel 网站位于不提供任何 shell 的共享虚拟主机上?

javascript - 如何在 JavaScript 中按下自定义警报框的“确定”按钮时重定向页面

php - Not Found 在此服务器上找不到请求的 URL/about。 laravel 路由

Symfony2 : How to install the dev-master version of Doctrine to resolve "Erroneous data format for unserializing" with composer?

php - 如何在 PHP/HTML 中显示 MySQL select 语句