itscaro/react-bundle

ReactPHP Bundle for Symfony2

Installs: 250

Dependents: 0

Suggesters: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Language:CSS

1.1.0 2015-10-01 13:11 UTC

README

Run Symfony apps under React-PHP.

This module adds enable the usage of ReactPHP server for Symfony.

No configuration is needed. Follow the Installation instructions and read Usage section to know how to start using ReactPHP with your Symfony APP.

Installation

Composer

To install the bundle through Composer, run the following command in console at your project base path:

php composer.phar require itscaro/react-bundle

Register bundle

Then register the new bundle in your AppKernel.

<?php
    
    // #app/AppKernel.php
    $bundles = array(
        ...
        new Itscaro\ReactBundle\JogaramReactBundle(),
        ...
    );
    

Usage

To start using ReactPHP with Symfony, open console, go to your project root path and execute the following command:

php app/console react:server:run --standalone

Available options

--host=127.0.0.1 Selects IP to run server at. Defaults to 127.0.0.1. --port=1337 Selects port to run server at, use comma to separate ports. Defaults to 1337. --standalone If passed, React server will serve static files directly. (Use this if you don`t have Apache or Nginx running in you local machine. Static file serving is not designed for production environments) --cache If passed, class loader will be enabled. --apc If passed, APC class loader will be enabled. This option requires --cache option. --sessionleader Available for background server, promote the forked process to be session leader

Background server

  • To start the server execute the following:
php app/console react:server:start
  • To stop the server, run:
php app/console react:server:stop

Note: If host and port are specified when starting the server, they must be specified for the stop command.

  • To restart the server:
php app/console react:server:restart

Using with web server as load balancer

Apache

<Proxy balancer://mycluster>
BalancerMember http://<ip:port of ReactPHP server>
BalancerMember http://<ip:port of ReactPHP server>
</Proxy>
ProxyPass / balancer://mycluster

Apache Document

Nginx

http {
    upstream mycluster {
        server <ip:port of ReactPHP server>;
        server <ip:port of ReactPHP server>;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://mycluster;
        }
    }
}

Nginx Document

Credits

Blackshawk