amphp/http-client
Asynchronous HTTP client for PHP built on Revolt with fibers and concurrency. Supports HTTP/1 & HTTP/2, concurrent requests, connection pooling, redirects, gzip/deflate decoding, streaming bodies, TLS by default, cookies/sessions, proxies, and custom methods—no ext/curl dependency.
Asynchronous Microservices & APIs:
curl-based calls with concurrent requests to reduce latency in APIs (e.g., aggregating data from multiple third-party services).Roadmap: Scalable Data Pipelines:
amphp/parallel) to offload I/O-bound tasks to worker pools.Build vs. Buy: Custom HTTP Logic:
PrivateCache interceptor).RetryRequests).CookieHandler, LogHttpArchive) to avoid reinventing wheels.Use Cases:
file_get_contents() or curl calls in monoliths with async workflows.LogHttpArchive).amp/scheduler, amphp/parallel) and need async HTTP.ext/curl.ext/curl (e.g., Docker Alpine, minimal PHP installs).Guzzle or Symfony HTTP Client may suffice.curl.Request/Response objects (unlike Artax).webonyx/graphql-php or clue/reactgraphql.*"This package lets us replace slow, blocking HTTP calls with asynchronous, concurrent requests, cutting latency by 10x for high-volume APIs. For example:
*"amphp/http-client is a high-performance, async HTTP library built for PHP’s fiber ecosystem. Key advantages:
curl dependency: Pure PHP implementation (HTTP/1.1 + HTTP/2).When to use it:
✅ Async APIs, real-time systems, or high-concurrency scraping.
✅ Replacing curl in fiber-based apps (e.g., with amp/scheduler).
✅ Need HTTP/2 or custom request/response logic.
Alternatives:
Guzzle for sync simplicity.Artax if you need PSR-7 immutability.Getting started:
composer require amphp/http-client
Example:
$client = HttpClientBuilder::buildDefault();
$response = $client->request(new Request('https://api.example.com/data'));
echo $response->getBody()->buffer(); // Async!
```*
**Pro tip**: Pair with `amphp/parallel` to distribute requests across fibers for max throughput."*
How can I help you explore Laravel packages today?