如何通过 composer 安装 league/OAuth2-client

How to install league/OAuth2-client through composer

我在尝试通过 composer 在 ubuntu 上安装 league/oauth2-client 时遇到错误,其中包含最新的 curl 和 openssl 库以及最新的 php 版本:

$ composer require league/oauth2-client
Using version ^0.12.1 for league/oauth2-client
./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 league/oauth2-client 1.0.x-dev -> satisfiable by league/oauth2-client[1.0.x-dev].
- Can only install one of: league/oauth2-client[0.12.1, 1.0.x-dev].
- Installation request for league/oauth2-client ^0.12.1 -> satisfiable by league/oauth2-client[0.12.1].

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

到目前为止,通过搜索答案找不到任何提示。预先感谢您对此的任何关注!

composer.json

的内容
$ cat composer.json 
{
    "name": "league/oauth2-client",
    "description": "OAuth 2.0 Client Library",
    "license": "MIT",
    "require": {
        "php": ">=5.5.0",
        "ext-curl": "*",
        "ircmaxell/random-lib": "~1.1",
        "guzzlehttp/guzzle": "~6.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "mockery/mockery": "~0.9",
        "squizlabs/php_codesniffer": "~2.0",
        "satooshi/php-coveralls": "0.6.*",
        "jakub-onderka/php-parallel-lint": "0.8.*"
    },
    "keywords": [
        "oauth",
        "oauth2",
        "authorization",
        "authentication",
        "idp",
        "identity",
        "sso",
        "single sign on"
    ],
    "authors": [
        {
            "name": "Alex Bilbie",
            "email": "hello@alexbilbie.com",
            "homepage": "http://www.alexbilbie.com",
            "role": "Developer"
        }
    ],
    "autoload": {
        "psr-4": {
            "League\OAuth2\Client\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "League\OAuth2\Client\Test\": "test/src/"
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "1.0.x-dev"
        }
    }
}

我认为您使用的 composer 有误。尝试 运行宁 composer install

来自作曲家文档:

The require command adds new packages to the composer.json file from the current directory. If no file exists one will be created on the fly.

The install command reads the composer.json file from the current directory, resolves the dependencies, and installs them into vendor.

所以如果 composer.json 是 league/oauth2-client 的 运行 composer install

如果您希望 league/oauth2-client 添加为其他包的依赖项,运行 composer require league/oauth2-client

我首先修复了此安装 knpuniversity/oauth2-client-bundle。所以你需要遵循这个顺序:

composer require knpuniversity/oauth2-client-bundle
composer require league/oauth2-client
composer require league/oauth2-facebook

这是我安装后的 composer.json 文件:

{
"knpuniversity/oauth2-client-bundle": "^1.9",
"league/oauth2-client": "^2.2",
"league/oauth2-facebook": "^2.0"
}

希望对您有所帮助