revolt / event-loop-adapter-react
Makes any ReactPHP based library run on top of the Revolt event loop.
Installs: 36 204
Dependents: 6
Suggesters: 1
Security: 0
Stars: 17
Watchers: 7
Forks: 1
Open Issues: 0
Requires
- php: >=8.1
- react/async: ^4
- react/event-loop: ^1 || ^0.5
- revolt/event-loop: ^1 || ^0.2.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^9.5.21
- psalm/phar: ^4.24
README
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();