Skip to content

Makes any ReactPHP based library run on top of the Revolt event loop.

License

Notifications You must be signed in to change notification settings

revoltphp/event-loop-adapter-react

Repository files navigation

event-loop-adapter-react

Stable License

revolt/event-loop-adapter-react makes any ReactPHP library run on top of the Revolt event loop.

Installation

composer require revolt/event-loop-adapter-react

Usage

Everywhere where a ReactPHP library requires an instance of LoopInterface, you just pass Loop::get() as normal. We automatically set up everything to run the ReactPHP library on the Revolt event loop.

<?php

require 'vendor/autoload.php';

use React\EventLoop\Loop;
use Revolt\EventLoop;

$app = function ($request, $response) {
    $response->writeHead(200, array('Content-Type' => 'text/plain'));
    $response->end("Hello World\n");
};

$socket = new React\Socket\Server(Loop::get());
$http = new React\Http\Server($socket, Loop::get());

$http->on('request', $app);
echo "Server running at http://127.0.0.1:1337\n";

$socket->listen(1337);

EventLoop::run();

About

Makes any ReactPHP based library run on top of the Revolt event loop.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages