j0k3r / graby

Graby helps you extract article content from web pages
MIT License
359 stars 72 forks source link

Document Symfony HttpClient #349

Open tacman opened 3 months ago

tacman commented 3 months ago

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
jtojnar commented 3 months ago

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.

tacman commented 3 months ago

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

jtojnar commented 3 months ago

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.

tacman commented 2 months ago

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.

jtojnar commented 2 months ago

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.