Composer安装laravel/socialite 2.0失败

4

composer require 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。

在Github上,socialite2.0的composer.json显示依赖关系为guzzlehttp 5.0/6.0。为什么我的安装程序要寻找guzzlehttp 4.0?

编辑-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

编辑-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"
}

}


1
你能发布你的composer.json文件吗? - Zoe Edwards
一种可能性是安装旧版本的aws/aws-sdk-php,例如该软件包的2.8版本。 - sk11z00
另一个解决方案是将您的 Laravel 版本更新到 5.3 或 5.4,以满足系统支持的要求。https://github.com/laravel/framework/blob/5.4/composer.json - sk11z00
@ThomasEdwards,我发布了composer.json。将guzzlehttp 4.2.4添加到require-dev中会显示aws-sdk-php依赖项。升级Laravel版本或降级aws-sdk-php需要大量的工作来验证应用程序。不幸的是,这不是一个选项。 - Krishna Chebrolu
顺便说一下,我的主要需求是允许用户从我们的网站上发布照片到FB/Twitter/G+(而不是链接)。有没有其他可用的替代方案来实现这个需求? - Krishna Chebrolu
现在,我有一个想法,过几分钟。存在一个名为composer.lock的文件。你能删除这个文件和文件夹vendor,然后再尝试运行命令:“composer require laravel/socialite ^2.0”吗? - sk11z00
5个回答

2
我有一个关于这个问题的想法。
在`composer.lock`中,保存您使用composer配置下载的软件包的哈希值和版本,可以是此时或其他时间。然后删除此文件和供应商文件夹,并再次执行:
composer require laravel/socialite ^2.0

2
以下是问题的解决方案:原来问题很简单。由于我仍在学习Composer的功能,之前无法解决。

将版本中的^更改为~就可以解决问题。根据掌握Composer - 小技巧,波浪号(~)和脱字符(^)都应该允许包中的小版本。但是,似乎“只需注意破坏性更改”优先于允许小版本。(至少,这是我得出的结论)。

以下是结果:

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

0

尝试:

composer require laravel/socialite

希望能对您有所帮助。
请参阅:Laravel文档

该命令将下载Socialite 3.0版本,但@krsna想要2.0版本。而Socialite 3.0版本要求Laravel的最低版本为5.4。这不是一个可选项和解决方案。 - sk11z00
1
版本不重要,它将正常工作。我认为他有一点困惑,如果他下载最新版本,则代码将无法运行。 - bipin

0
在编写文件中添加"laravel/socialite": "2.*",然后运行 composer update composer dump-autoload

0
尝试这个:composer require laravel/socialite:~2.0 对我有用 :)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接