What's the difference between:
How they differ and what would be typical use case to use with?
What's the difference between:
How they differ and what would be typical use case to use with?
The main difference between those is that Guzzle is an HTTP client, while Amp and ReactPHP are generic async / event loop libraries. Both of these offer HTTP clients based on the core event loop they offer. Those are amphp/artax
and reactphp/http-client
.
Now, the difference between those and Guzzle is that those can do other things concurrently that are not HTTP requests. That is, because the user has full control over the event loop and can register own I/O watchers and timers, while the event loop that Guzzle uses is hidden from the user inside Curl.
If you just want to make a few concurrent HTTP requests, the decision mainly boils down to the API you like and a performance consideration maybe. If you want to do other I/O related things concurrently, use Amp or ReactPHP. If you want to stream your bodies, I'd suggest against using Guzzle, too.
Hey ReactPHP core team member here. Both ReactPHP and Amp assume you're building an app with an event loop. If you just want to do a bunch of async requests and then continue, I would suggest using Guzzle's async requests: http://docs.guzzlephp.org/en/stable/quickstart.html#async-requests
If how ever you want to dive deeper into async request I suggest https://github.com/clue/php-buzz-react which gives you more control over the process plus it supports PSR-7.
Amp\Promise\wait()
specifically for applications that are not entirely asynchronous. ReactPHP offers similar functions in the external clue/php-block-react
package. The major difference between those and Guzzle is that Amp and ReactPHP additionally allow other non-blocking I/O and timers, not only concurrent HTTP requests. –
Tantalum $promise->wait()
synchronnous handler - github.com/guzzle/promises. –
Perseid © 2022 - 2024 — McMap. All rights reserved.