revolt/event-loop
Revolt is a rock-solid event loop for concurrent PHP 8.1+ apps using fibers. It enables non-blocking I/O with synchronous code, serving as a minimal, shared scheduler base for libraries like Amp and ReactPHP.
DB::connection() or Http::get() in suspensions) or via Laravel’s event system (e.g., bus:dispatch with fiber-aware queues).Illuminate\Support\Facades) but requires adapters for synchronous APIs (e.g., converting DB::select() to a fiber suspension).revolt/uv) for high-performance I/O. Apache/Nginx + PHP-FPM may need tuning (e.g., pm.max_children, pm.start_servers).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Fiber Leaks | High | Enforce suspension resumption in cleanup hooks (e.g., register_shutdown_function). |
| Blocking Laravel Core | High | Isolate Revolt to non-critical paths (e.g., background jobs, WebSocket handlers). |
| PHP Version Lock | Medium | Requires PHP 8.1+; may block upgrades if Laravel lags. |
| Debugging Complexity | Medium | Fibers add stack trace complexity; use FiberLocal for context logging. |
| Extension Dependencies | Medium | revolt/uv or revolt/libuv needed for high-performance I/O. |
| State Management | Low | Use FiberLocal for request-scoped data (e.g., auth tokens). |
bus:dispatch) be fiber-aware?App\Exceptions\Handler)?uv, libuv) compatible with the hosting environment?DB::connection() in fiber suspensions (e.g., Revolt\EventLoop\Suspension).Http::get() with Revolt\Http\Client (if available) or a custom fiber wrapper.bus:dispatch via a fiber-aware queue worker.revolt/uv (default) or revolt/libuv for high-performance I/O.revolt/pcntl for multi-process support (if needed).| Phase | Actionable Steps | Risks |
|---|---|---|
| Proof of Concept | 1. Replace a single blocking call (e.g., DB::select()) with a fiber suspension. |
Limited scope; may not show scalability. |
| Service Layer | 2. Wrap database/HTTP clients in fiber-aware services. | Breaking changes if APIs aren’t suspension-friendly. |
| Event System | 3. Integrate with Laravel’s events/listeners (e.g., Event::dispatch in fibers). |
Event listeners may not be fiber-safe. |
| WebSocket API | 4. Replace Echo/Pusher with Revolt’s WebSocket server. | Requires custom middleware. |
| Queue Workers | 5. Rewrite workers to use fiber suspensions (e.g., bus:work --fiber). |
May need custom queue driver. |
Revolt\EventLoop\Suspension (e.g., revolt/http).ReactPHP → Revolt).FiberLocal to log fiber context (e.g., request ID).Fiber::getCurrent() for context.EventLoop::getSuspensions()).FiberLocal to attach request IDs or correlation IDs to logs.$fiberLocal = new FiberLocal();
$fiberLocal->set('request_id', $request->id);
EventLoop::setErrorHandler(fn (Throwable $e) => report($e));
RevoltServiceProvider).pm.max_children).FiberLocal for session data).pcntl_fork).How can I help you explore Laravel packages today?