neur0toxine / psr.http-client-implementation.php-http-curl
使用用户提供的包满足"psr/http-client-implementation",如果没有满足初始要求,则回退到"php-http-curl"。
1.1
2021-05-21 10:00 UTC
This package is auto-updated.
Last update: 2024-09-21 17:20:04 UTC
README
提供一个元包,用于需要psr/http-client-implementation
的库,当用户未满足初始要求时回退到默认实现。
使用方法
composer require "Neur0toxine/psr.http-client-implementation.php-http-curl:*"
Composer会优先
- 使用用户提供的实现
- 否则,回退到
php-http/curl-client
它是如何工作的
此包包含2个版本
当用户已经有一个满足psr/http-client-implementation
的包时,Composer将选择这个最高版本。否则,Composer将选择最低版本,在这种情况下,将下载以下包:php-http/curl-client
。
它解决了什么问题?
你维护了一个需要psr/http-client-implementation
实现的库,但你不想要求特定的实现。
例如,你是以下composer.json的维护者
{ "name": "acme/lib", "require": { "psr/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 psr/http-client-implementation ^1.0 -> no matching package found.
你可以要求用户安装一个随机的包,这可以工作,但用户体验很差,一开始很混乱。
通过使用Neur0toxine/psr.http-client-implementation.php-http-curl
,用户将能够要求他们偏好的实现或回退到你的默认选择
满足首选要求的用户示例
{ "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 Neur0toxine/psr.http-client-implementation.php-http-curl (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 Neur0toxine/psr.http-client-implementation.php-http-curl (1.0) - Installing php-http/curl-client (1.0)
贡献
此存储库是自动生成的。如果你想贡献并提交问题或拉取请求,请使用composer-fallback/generator。