dev-master
9999999-devAn event based optionally forking PHP application server built on top of ReactPHP
GPL-2.0
The Requires
by Frode Borli
asynchronous forking application-server
Wallogit.com
2017 © Pedro Peláez
An event based optionally forking PHP application server built on top of ReactPHP
Fubber Reactor is an event driven and forking PHP application server based on the excellent ReactPHP event driven PHP framework. Fubber Reactor is an invitation to contribute in developing an awesome PHP application server that combines the best of PHP with the best of node.js., (*1)
The simplest way to configure Fubber Reactor is via composer. Simply follow these steps:, (*2)
Download and install composer (skip if you already have done this), (*3)
curl -sS https://getcomposer.org/installer | php, (*4)
Add Fubber Reactor as a dependency to your project, (*5)
./composer.phar require fubber/reactor:dev-master, (*6)
Start Fubber Reactor, (*7)
./vendor/bin/fubber-reactor, (*8)
That's it! The default application should be serving at http://localhost:1337/. Check out the wiki for help on how to actually do some work!, (*9)
With Fubber Reactor you'll configure URL-paths that map to instances of controller classes (beans). There are currently two types of controller classes:, (*10)
The ordinary controller is used for page requests that should be run and handled within the standard ReactPHP event loop. The code running inside this controller should be non-blocking. This allows you to respond very quickly to page requests, and you'll also be able to maintain a client connection for a very long time, without incurring too much system overhead while doing so. Simply store a reference to the Response object in memory and whenever you want to write to it, just do so., (*11)
The forking controller is special, in that it actually spawns off a fork of the main process. This allows you to perform non-blocking algorithms and requests, in a very similar manner to traditional PHP development. An average server can handle a few hundred running forking controllers, but the server will only allow a fork to run for up to 30 seconds. After 30 seconds, the server will dispatch a SIGHUP signal telling the controller to shut down. This will eventually be configurable., (*12)
Fubber Reactor has a special file based routing scheme. Every route is set up by creating an INI-file in the pages/ folder. The INI-files contains information about which class should be handling the request. In the current version, Fubber Reactor will instansiate an instance of the class for every URL you configure. Every request will then be sent to the Controller::listen($request, $response) method. That method will in turn call Controller::get($request, $response) for GET requests, Controller::post($request, $response) for POST requests and so on., (*13)
To create a route for a URL such as /users/12345/ you'll simply create an INI-file /pages/users/_/index.ini. This will cause an instance of your controller to get every request that maps to /pages/users/*/ according to the fnmatch() function., (*14)
Fubber Reactor is a work in progress. I have a working and scalable publisher/subscriber server that will serve as an example application, and you can use that for sending push requests to your audience - for example to create a Twitter like experience, or something like a chat room., (*15)
These features are on my short-list:, (*16)
An event based optionally forking PHP application server built on top of ReactPHP
GPL-2.0
asynchronous forking application-server