Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Http Client Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

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.

Implementation Patterns

  • Use ClientBuilder to configure timeouts, connection limits, and HTTP/2 support.
  • Leverage Amp\asyncCall() and Amp\Promise\wait() for mixing async requests inside CLI scripts or Swoole/ReactPHP event loops.
  • Integrate with Laravel via custom services (e.g., AmpHttpClientService) or middleware that wraps the client—important for non-blocking HTTP calls inside job queues or scheduled tasks.
  • Implement retry logic with Amp\Retry\retry() for transient failures.
  • Chain interceptors (e.g., logging, auth headers) using RequestInterceptor to centralize concerns across requests.

Gotchas and Tips

  • Amp\Promise\wait() blocks the current event loop—avoid calling it inside async contexts like coroutine-based workers.
  • OpenSSL configuration mismatches (e.g., missing CA bundles) cause silent handshake failures—ensure openssl.cafile is set or use Amp\Loop::onExpand() for custom certs.
  • HTTP/2 multiplexing can cause head-of-line blocking; use separate clients per host if latency-sensitive.
  • Debug with Amp\Http\Client\Interceptor\DebugInterceptor or enable Amp\Log\StreamHandler for detailed request/response tracing.
  • The client is not PSR-18 compliant out of the box—use amphp/psr-18-adapter for compatibility if required by other packages.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport