-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REQ][PHP] depend on meta packages providing the HTTP implementation instead of directly on Guzzle #7518
Comments
This became more important since the used features got deprecated, for example
|
Hey @dkarlovi , just wanted to ask you if you started working on this or if this is just an issue for reference. (or maybe @ybelenko ? Saw your name in other php-related stuff). We at https://www.cdn77.com are now in need of this, so ... if you or somebody else isn't working on this, I'd look into it. |
@grongor I was thinking about doing it, but I opened an issue instead at the time. :) If you have the resources to do it, feel free to do so. 👍 |
It doesn't look like simply depending on
Depending on I would consider explicitly depending on any of the psr7 implementation packages less abstract, but also a good hassle-free solution. (for serializing query, payload, etc) |
I'd like to take a stab at this. How should this effort be organized? Will it work if I add a new generator |
@rauanmayemir go for it. Since it will be BC, you can target the regular PHP generator. |
Here's an example of doing it for another lib: $body = $this->streamFactory->createStream(json_encode($convertedSpans));
$request = $this->requestFactory
->createRequest('POST', $this->endpointUrl)
->withBody($body)
->withHeader('content-type', 'application/json');
$response = $this->client->sendRequest($request); See the full example here: https://gist.github.com/dkarlovi/ec38d1c4cc47b85609c6e2bffa2451e5 See the rationale here: open-telemetry/opentelemetry-php#223 (comment) |
@dkarlovi It's great that we're on the same page. I also saw depending on P.S: Planning to dig into it this weekend. |
@rauanmayemir were you able to makeany progress here? |
Sorry, dropped the ball here. Feel free to start working on it yourself if it's urgent. |
@rauanmayemir didn't mean to imply you had to do it, I just wanted to verify if you made any progress so the work is not wasted. :) Thanks, I'll very likely tackle it soon-ish. |
Hi @dkarlovi I made similar work updating one API so it does not depend on any particular http client following the ideas mentioned in the discussion. I created a few custom templates and generated an API for myself. The API I was working on is pretty basic with a limited number of use cases. Maybe a broke a lot of things unknowingly, I will follow CONTRIBUTING guide and create a PR shortly, bringing custom templates to php generator |
Is your feature request related to a problem? Please describe.
Currently, the packages generated by
php
depend on Guzzle, like soThis 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.
The text was updated successfully, but these errors were encountered: