2017 © Pedro PelĂĄez
 

library silex-react-renderer-provider

Client and Server-side react rendering as a Silex service provider

image

teameh/silex-react-renderer-provider

Client and Server-side react rendering as a Silex service provider

  • Wednesday, May 9, 2018
  • by teameh
  • Repository
  • 2 Watchers
  • 3 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

Silex React Renderer Service Provider

WARNING: Silex and this project are not maintained any more. Ends of life of Silex is set to June 2018., (*1)

Read more on Symfony's blog., (*2)

ReactRenderer

This provider integrates ReactRenderer in your Silex project. This lets you implement your frontend with React.js and let php do the server-side rendering, allowing the development of universal (isomorphic) applications., (*3)

See https://github.com/Limenius/ReactRenderer for full documentation on the renderer., (*4)

Usage

Basic example, (*5)

$app = new Silex\Application();
$app->register(new Teameh\Silex\Services\React\ReactRendererServiceProvider(), [
    'react.serverside_rendering' => [
        // using phpexecjs: 
        'server_bundle_path' => __DIR__ . '/path/to/your/javascript/development/bundle.js'
        // or using and external render server:
        // 'socket_server_path' => 'unix://node.sock'
    ]
]);

All config options, (*6)

$app = new Silex\Application();

$app->register(new Teameh\Silex\Services\React\ReactRendererServiceProvider(), [
    'react.default_rendering' => $app['debug'] ? 'client_side' : 'both',
    'react.serverside_rendering' => [
        'fail_loud' => $app['debug'],
        'trace' => $app['debug'],
        'mode' => 'phpexecjs',
        // using phpexecjs:
        'server_bundle_path' => __DIR__ . '/path/to/your/javascript/development/bundle.js',
        // or using and external render server:
        // 'socket_server_path' => 'unix://node.sock',
        'logger' => $app['monolog'],
    ]
]);

Configuration options:, (*7)

react.default_rendering:      string, either 'client_side', 'server_side' or 'both'

react.serverside_rendering:
    fail_loud                   bool, defaults to $app['debug']
                                  In case of error in server-side rendering, throw exception

    trace                       bool, defaults to $app['debug']
                                  Replay every console.log message produced during server-side rendering in the
                                  JavaScript console. Note that if enabled it will throw a (harmless) React warning

    mode                        string
                                  Mode can be `"phpexecjs"` (to execute Js from PHP using PhpExecJs),
                                  or `"external"` (to rely on an external node.js server) Default is `"phpexecjs"`

    string server_bundle_path   string (Only used with mode `phpexecjs`)
                                  Location of the server bundle, that contains the concatenated javascript bundle.
                                  This bundle should contain the ReactOnRails.register() code

    socket_server_path          string (Only used with mode `external`)
                                  Location of the socket to communicate with a dummy node.js server.
                                  Socket type must be acceptable by php function stream_socket_client.
                                  Example unix://node.sock, tcp://127.0.0.1:5000
                                  More info: http://php.net/manual/en/function.stream-socket-client.php
                                  Example of node server:
                                  https://github.com/Limenius/symfony-react-sandbox/blob/master/app/Resources/node-server/server.js

    logger                      \Psr\Log\LoggerInterface
                                  Logger used for errors

Rendering can be overridden on component basis, see https://github.com/Limenius/ReactRenderer, (*8)

Credits

This project is a Silex adaption of Nacho MartĂ­n's great ReactBundle., (*9)

Both ReactBundle and this provider build on top of React On Rails, and uses react-on-rails to render React components. Don't worry you don't need and won't see any Ruby when using this package., (*10)

The Versions

09/05 2018

dev-master

9999999-dev https://github.com/teameh/silex-react-renderer-provider

Client and Server-side react rendering as a Silex service provider

  Sources   Download

MIT

The Requires

 

twig silex react reactjs isomorphic

08/07 2017

v0.14.0

0.14.0.0 https://github.com/teameh/silex-react-renderer-provider

Client and Server-side react rendering as a Silex service provider

  Sources   Download

MIT

The Requires

 

twig silex react reactjs isomorphic

08/07 2017

v0.13.0

0.13.0.0 https://github.com/teameh/silex-react-renderer-provider

Client and Server-side react rendering as a Silex service provider

  Sources   Download

MIT

The Requires

 

twig silex react reactjs isomorphic

11/04 2017

v0.12.0

0.12.0.0 https://github.com/teameh/silex-react-renderer-provider

Client and Server-side react rendering as a Silex service provider

  Sources   Download

MIT

The Requires

 

twig silex react reactjs isomorphic