webpatser/fledge-fiber-http

Non-blocking Fiber-based HTTP client handler for Fledge/Laravel using amphp

Maintainers

Package info

github.com/webpatser/fledge-fiber-http

pkg:composer/webpatser/fledge-fiber-http

Statistics

Installs: 4

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v13.3.0.0 2026-04-06 14:16 UTC

This package is auto-updated.

Last update: 2026-04-06 14:17:33 UTC


README

Non-blocking, Fiber-based HTTP client handler for Fledge and Laravel 13 using amphp/http-client.

Replaces Guzzle's default CurlHandler with an amphp-based handler that suspends PHP Fibers during I/O. Multiple concurrent HTTP requests progress in parallel without blocking.

Requirements

  • PHP 8.5+
  • Fledge / Laravel 13 (with Factory::globalHandler() support)
  • amphp/http-client ^5.3 (included)

Installation

composer require webpatser/fledge-fiber-http

The service provider is auto-discovered. All Http::get(), Http::post(), etc. calls automatically use the non-blocking handler.

How It Works

Every HTTP request made through Laravel's HTTP client (Http facade, PendingRequest) is dispatched via amphp's event loop:

  1. The request is sent on the socket
  2. The current Fiber suspends while waiting for the response
  3. Other Fibers progress (database queries, Redis operations, etc.)
  4. When the response arrives, the Fiber resumes

All Guzzle middleware (retries, logging, authentication) works unchanged — the handler only replaces the transport layer.

Concurrent Requests

Laravel's Http::pool() benefits automatically — each request in the pool runs in a separate Fiber:

$responses = Http::pool(fn (Pool $pool) => [
    $pool->get('https://api.example.com/users'),
    $pool->get('https://api.example.com/posts'),
    $pool->get('https://api.example.com/comments'),
]);

Per-Request Handler Override

To use a different handler for specific requests:

Http::setHandler(new \GuzzleHttp\Handler\CurlHandler)
    ->get('https://example.com');

Testing

composer test

License

MIT