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

Event Loop Adapter React Laravel Package

revolt/event-loop-adapter-react

Run ReactPHP libraries on the Revolt event loop. This adapter lets you pass React\EventLoop\Loop::get() where a LoopInterface is required, automatically bridging ReactPHP components to Revolt for a single, unified loop.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package with composer require revolt/event-loop-adapter-react. This adapter bridges ReactPHP’s LoopInterface to Revolt’s event loop—no code changes required beyond replacing React\EventLoop\LoopFactory::create() with Revolt\EventLoop\Loop::get(). Start by building a minimal ReactPHP-based server (e.g., HTTP or socket) using Loop::get() as the loop instance, then invoke Revolt\EventLoop::run() to start execution. The README’s HTTP server snippet is the canonical reference—copy, tweak the app logic, and run.

Implementation Patterns

  • Drop-in loop replacement: In any ReactPHP-dependent component (e.g., react/http, react/socket, react/dns), pass Revolt\EventLoop\Loop::get() wherever LoopInterface is expected.
  • Unified runner: Always use Revolt\EventLoop::run() to start the event loop—never React\EventLoop\Loop::run(), to ensure all hooks delegate to Revolt.
  • Hybrid workflows: Ideal for projects migrating from ReactPHP to Revolt incrementally (e.g., keeping existing React-based WebSocket handlers while adopting Revolt for async I/O).
  • Framework integration: Use in custom Laravel workers (e.g., long-running CLI processes or Octane coroutines) where ReactPHP libraries are explicitly required—just ensure your app entrypoint explicitly starts EventLoop::run().

Gotchas and Tips

  • Singleton risk: Loop::get() returns a persistent singleton—do not mix it with React\EventLoop\LoopFactory::create(), or you risk duplicate loop instances and erratic behavior.
  • Signal handling: Pre-v1.1.1 versions fail to propagate signals (e.g., SIGTERM) to ReactPHP handlers; pin to ^1.1.1 if signalGracefulShutdown is needed.
  • No extra setup: Avoid calling Loop::enable() or similar—this adapter auto-wires React’s hooks into Revolt on first use.
  • Debugging timeouts: If deferred callbacks/timers stall, confirm EventLoop::run() is called after all subscriptions, and inspect for uncaught exceptions in deferred stacks (Revolt’s loop throws stricter timing errors).
  • Dependency vigilance: Though it depends on both react/event-loop and revolt/event-loop, you never instantiate React’s loop directly—the adapter only works via Loop::get().
  • Adoption caution: With 0 dependents and last release in 2023, verify compatibility with newer ReactPHP versions manually before production deployment—especially for mission-critical services.
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