graby icon indicating copy to clipboard operation
graby copied to clipboard

Document Symfony HttpClient

Open tacman opened this issue 1 year ago • 5 comments

Since the http client is decoupled, this should install with the Symfony HttpClient. If this is correct, can it be added to the docs?

composer require 'j0k3r/graby dev-master'  symfony/http-client nyholm/psr7:^1.0

tacman avatar Mar 15 '24 22:03 tacman

Looks like it does provide http-client-implementation:

https://github.com/symfony/http-client/blob/cb5f957b5583278194080da3ffaa086eb65c5b38/composer.json#L19C10-L21

And https://github.com/Nyholm/psr7 looks neat.

But we would need to test it to be sure.

jtojnar avatar Mar 15 '24 22:03 jtojnar

The Symfony HttpClient is async by default, and implements HttpPlug Promises, perhaps it is a solution for #323 .

tacman avatar Mar 15 '24 22:03 tacman

We still need async support in Graby itself, which is what #323 attempts to do.

Unfortunately, the HttpPlug promises had limitations that blocked this. Not sure if anything changed.

jtojnar avatar Mar 16 '24 00:03 jtojnar

I'm far from an expert on this, but I think HttpPlug can be dropped in favor of https://github.com/Nyholm/psr7, as HttpPlug was written before some of the PSR's. But it's like going down a rabbit hole to start reading about how to set up contracts and adapters.

Maybe in a new version.

tacman avatar Mar 16 '24 18:03 tacman

Nyholm/psr7 is just one implementation of PSR-7. PSR-7 defines interfaces for HTTP messages. We need to target PSR-7 itself to be able to use other implementations.

HttpPlug is still needed because it is the closest thing to PSR-18 for async HTTP clients. Some parts of HTTPlug were already superseded by PSR-7 and PSR-18 and HTTPlug switched to them in those places.

jtojnar avatar Mar 16 '24 19:03 jtojnar