PHP code example of ordinaryjellyfish / flarum-react
1. Go to this page and download the library: Download ordinaryjellyfish/flarum-react 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/ */
ordinaryjellyfish / flarum-react example snippets
use OrdinaryJellyfish\FlarumReact\Server as FlarumServer;
use React\Promise\Promise;
$loop = React\EventLoop\Factory::create();
$server = new React\Http\Server(function ($request) {
return new Promise(function ($resolve) use ($request) {
$flarumServer = (new FlarumServer(
$request,
Flarum\Foundation\Site::fromPaths([
'base' => __DIR__.'/..',
'public' => __DIR__.'/../public',
'storage' => __DIR__.'/../storage',
])
));
$flarumServer->listen();
$resolve($flarumServer->getResponse());
});
});
$socket = new React\Socket\Server(8080, $loop);
$server->listen($socket);
$loop->run();