webpatser / fledge-fiber-http
Non-blocking Fiber-based HTTP client handler for Fledge/Laravel using amphp
Requires
- php: ^8.5
- amphp/http-client: ^5.3
- guzzlehttp/guzzle: ^7.8
- guzzlehttp/psr7: ^2.4
- illuminate/http: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
- mockery/mockery: ^1.6
- pestphp/pest: ^4.0
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:
- The request is sent on the socket
- The current Fiber suspends while waiting for the response
- Other Fibers progress (database queries, Redis operations, etc.)
- 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