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

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Asynchronous Microservices & APIs:

    • Build high-performance, non-blocking HTTP clients for microservices, event-driven architectures, or real-time systems (e.g., WebSockets, SSE, or async task queues).
    • Replace synchronous curl-based calls with concurrent requests to reduce latency in APIs (e.g., aggregating data from multiple third-party services).
  • Roadmap: Scalable Data Pipelines:

    • Enable parallel HTTP requests for ETL pipelines, scraping, or batch processing (e.g., fetching 100+ endpoints concurrently).
    • Integrate with AMPHP’s fiber ecosystem (e.g., amphp/parallel) to offload I/O-bound tasks to worker pools.
  • Build vs. Buy: Custom HTTP Logic:

    • Build: Use interceptors to implement:
      • Request/response transformations (e.g., API key injection, rate limiting).
      • Caching layers (via PrivateCache interceptor).
      • Retry logic with exponential backoff (RetryRequests).
    • Buy: Leverage existing interceptors (e.g., CookieHandler, LogHttpArchive) to avoid reinventing wheels.
  • Use Cases:

    • Real-time systems: Concurrent WebSocket/API polling (e.g., stock tickers, live sports).
    • Serverless: Async HTTP calls in PHP-based serverless functions (e.g., AWS Lambda, Bref).
    • Legacy modernization: Replace blocking file_get_contents() or curl calls in monoliths with async workflows.
    • Observability: Log HTTP traffic to HAR files for debugging/profiling (e.g., LogHttpArchive).

When to Consider This Package

Adopt If:

  • Your PHP app requires high concurrency (e.g., >100 parallel HTTP requests) and blocking I/O is a bottleneck.
  • You’re using AMPHP’s fiber ecosystem (e.g., amp/scheduler, amphp/parallel) and need async HTTP.
  • You need HTTP/2 support (multiplexing, header compression) without ext/curl.
  • You require fine-grained control over requests/responses (e.g., custom interceptors for auth, retries, or caching).
  • Your stack prohibits ext/curl (e.g., Docker Alpine, minimal PHP installs).

Look Elsewhere If:

  • You need simplicity: For basic sync requests, Guzzle or Symfony HTTP Client may suffice.
  • Your app is synchronous: No fiber support = no performance gain over curl.
  • You rely on PSR-7 immutability: This library uses mutable Request/Response objects (unlike Artax).
  • You need graphql/subscriptions: Consider webonyx/graphql-php or clue/reactgraphql.
  • Your team lacks async PHP experience: Steep learning curve for fibers/interceptors.

How to Pitch It (Stakeholders)

For Executives:

*"This package lets us replace slow, blocking HTTP calls with asynchronous, concurrent requests, cutting latency by 10x for high-volume APIs. For example:

  • Faster data pipelines: Fetch 100+ endpoints in parallel instead of sequentially.
  • Scalable microservices: Handle thousands of WebSocket/API connections without blocking threads.
  • Cost savings: Reduce server resources by offloading I/O to fibers (no need for more workers). It’s MIT-licensed, battle-tested (used in Revolt’s infrastructure), and integrates with our existing PHP stack. The tradeoff? A slight learning curve for async patterns—but the performance gains justify it for performance-critical paths."*

For Engineers:

*"amphp/http-client is a high-performance, async HTTP library built for PHP’s fiber ecosystem. Key advantages:

  • No curl dependency: Pure PHP implementation (HTTP/1.1 + HTTP/2).
  • Concurrency by default: Fire-and-forget requests with connection pooling.
  • Extensible: Add interceptors for retries, caching, auth, or logging (e.g., HAR files).
  • Modern PHP: Works with fibers, streams large responses efficiently, and supports TLS securely.

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:

  • Use Guzzle for sync simplicity.
  • Use Artax if you need PSR-7 immutability.
  • Avoid if your app is purely synchronous.

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."*
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope