1. Go to this page and download the library: Download react-parallel/event-loop library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
react-parallel / event-loop example snippets
use React\EventLoop\Factory;
use ReactParallel\EventLoop\EventLoopBridge;
$loop = Factory::create();
$eventLoopBridge = new EventLoopBridge($loop);
$loop->run();
use parallel\Channel;
use React\EventLoop\Factory;
use ReactParallel\EventLoop\EventLoopBridge;
$loop = Factory::create();
$eventLoopBridge = new EventLoopBridge($loop);
$channel = new Channel(Channel::Infinite);
$eventLoopBridge->observe($channel)->subscribe(function (string $message) {
echo $message, PHP_EOL;
});
$loop->futureTick(function () use ($channel): void {
$channel->send('Hello World!');
$channel->close();
});
$loop->run();
use parallel\Channel;
use React\EventLoop\Factory;
use ReactParallel\EventLoop\EventLoopBridge;
use function parallel\run;
$loop = Factory::create();
$eventLoopBridge = new EventLoopBridge($loop);
$future = run(function (): string {
return 'Hello World!';
});
$channel = new Channel(Channel::Infinite);
$eventLoopBridge->await($future)->then(function (string $message) {
echo $message, PHP_EOL;
});
$loop->run();
use React\EventLoop\Factory;
use ReactParallel\EventLoop\EventLoopBridge;
use ReactParallel\EventLoop\Metrics;
use WyriHaximus\Metrics\Configuration;
use WyriHaximus\Metrics\InMemory\Registry;
$loop = Factory::create();
$eventLoopBridge = (new EventLoopBridge($loop))->withMetrics(Metrics::create(new Registry(Configuration::create())));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.