[REQ][PHP] depend on meta packages providing the HTTP implementation instead of directly on Guzzle
See original GitHub issueIs your feature request related to a problem? Please describe.
Currently, the packages generated by php
depend on Guzzle, like so
{
"require": {
"php": ">=7.2",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
}
}
This is functional, but not ideal, making it harder to swap out HTTP clients, like for example Symfony HTTP Client if you’re using Symfony.
Being able to choose your desired HTTP client is very desirable in modern PHP apps since you might have existing clients already, setup to log requests via telemetry, use caching, etc.
Describe the solution you’d like
Instead of relying on Guzzle directly, depend on a psr/http-client-implementation
(AKA PSR 18). This is a metapackage which implementations can declare they provide, all the major ones already do (including Guzzle, Symfony, etc).
Describe alternatives you’ve considered
Alternatively, the client implementation to select might be php-http/async-client-implementation
(since the client is expected to be async). The offered implementations are fewer, but the major ones are still there. Result is the same: developer being able to inject their desired client.
This could also be done both ways: depend on the regular client, check if it’s one of the async ones at runtime and allow async ops if so.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:13 (7 by maintainers)
Top GitHub Comments
Sorry, dropped the ball here. Feel free to start working on it yourself if it’s urgent.
@dkarlovi It’s great that we’re on the same page. I also saw depending on
http-factory-implementation
as both correct way and lesser evil. As for the use of guzzle’s helper functions, I think it can be discarded in favor of PHP built-in functions. (guzzle mostly just wraps them anyway)P.S: Planning to dig into it this weekend.