ordinaryjellyfish / flarum-react
Run Flarum using your own ReactPHP HTTP server
0.3.0
2020-03-13 03:01 UTC
Requires
- flarum/core: ^0.1.0-beta.12
- react/http: ^0.8.5
This package is auto-updated.
Last update: 2024-11-13 13:55:25 UTC
README
A simple library to serve Flarum over ReactPHP HTTP servers.
Installation
composer require ordinaryjellyfish/flarum-react
Usage
In your Flarum's index.php
file:
require '../vendor/autoload.php'; 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();
Visit http://localhost:8080 and voila! The beauty of Flarum arises. Note that this example does not handle static file serving. I may implement a handler to make everything simpler.