amphp/http-client
Async HTTP client for PHP built on Amp. Send concurrent requests with connection pooling, timeouts, redirects, proxies, TLS support, and streaming request/response bodies. Includes PSR-7/PSR-18 integration and middleware-style interceptors.
Install via Composer: composer require amphp/http-client. Start by creating a basic HttpClient instance using Amp\Http\Client\ClientBuilder, then dispatch requests with request(). For your first use case, replace synchronous file_get_contents() or Guzzle-based sync requests with concurrent async calls—for example, fetching multiple external API endpoints in parallel with Amp\Promise::all() to reduce total response time.
ClientBuilder to configure timeouts, connection limits, and HTTP/2 support.Amp\asyncCall() and Amp\Promise\wait() for mixing async requests inside CLI scripts or Swoole/ReactPHP event loops.AmpHttpClientService) or middleware that wraps the client—important for non-blocking HTTP calls inside job queues or scheduled tasks.Amp\Retry\retry() for transient failures.RequestInterceptor to centralize concerns across requests.Amp\Promise\wait() blocks the current event loop—avoid calling it inside async contexts like coroutine-based workers.openssl.cafile is set or use Amp\Loop::onExpand() for custom certs.Amp\Http\Client\Interceptor\DebugInterceptor or enable Amp\Log\StreamHandler for detailed request/response tracing.amphp/psr-18-adapter for compatibility if required by other packages.How can I help you explore Laravel packages today?