composer-fallback/php-http.client-implementation.symfony

使用用户提供的包满足 "php-http/client-implementation",如果没有满足初始要求,则回退到 "symfony"。

1.1 2020-10-02 12:33 UTC

This package is auto-updated.

Last update: 2024-08-29 05:37:09 UTC


README

为需要 php-http/client-implementation 且在用户不满足初始要求时回退到默认实现的库提供元包。

用法

composer require "composer-fallback/php-http.client-implementation.symfony:*"

Composer 会优先

  • 使用用户提供的实现
  • 否则,回退到 symfony/http-client

工作原理

此包包含 2 个版本

  1. 最高版本 1.1 满足您的需求即可。

  2. 最低版本 1.0 将触发 symfony/http-client 的安装。

当用户已经有一个满足 php-http/client-implementation 的包时,Composer 将选择此最高版本。否则,Composer 将选择最低版本,并在这种情况下下载以下包: symfony/http-client

它解决了什么问题?

您正在维护一个需要 php-http/client-implementation 实现的库,但您不想要求特定的实现。

例如,您是以下 composer.json 的维护者

{
  "name": "acme/lib",
  "require": {
    "php-http/client-implementation": "^1.0",
  }
}

当最终用户使用以下代码请求您的库时

{
    "name": "end-user/app",
    "require": {
      "acme/lib": "^1.0"
    }
}

他们可能会遇到这样的错误

composer up

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

  Problem 1
    - Installation request for acme/lib ^1.0 -> satisfiable by acme/lib[1.0].
    - acme/lib 1.0 requires php-http/client-implementation ^1.0 -> no matching package found.

您可以要求用户安装一个随机的包,它有效,但体验非常糟糕,一开始会令人困惑。

通过使用 composer-fallback/php-http.client-implementation.symfony,用户将能够要求他们偏好的实现或回退到您的默认选择

满足首选要求的用户示例

{
    "name": "end-user/app",
    "require": {
        "acme/lib": "^1.0",
        "third-party/provide-implementation": "^1.0"
    }
}
composer up
...
Package operations: 2 installs, 0 updates, 0 removals
  - Installing acme/lib (1.0)
  - Installing composer-fallback/php-http.client-implementation.symfony (1.1)

回退到您推荐的用户的示例

{
    "name": "end-user/app",
    "require": {
        "acme/lib": "^1.0"
    }
}
composer up
...
Package operations: 3 installs, 0 updates, 0 removals
  - Installing acme/lib (1.0)
  - Installing composer-fallback/php-http.client-implementation.symfony (1.0)
  - Installing symfony/http-client (1.0)

替代方案

贡献

此存储库是自动生成的。如果您想贡献并提交问题或拉取请求,请使用 composer-fallback/generator