qpautrat/reactjs-php-bundle

Render ReactJS component in server side using reactjs/react-php-v8js

1.0.0 2015-08-11 09:55 UTC

This package is auto-updated.

Last update: 2024-10-12 03:44:52 UTC


README

Render ReactJS components in server side using reactjs/react-php-v8js

Prerequisites

V8Js PHP extension

Installation

composer require qpautrat/reactjs-php-bundle

Whitelist following library in require section until maintainers release a version on packagist

"reactjs/react-php-v8js": "*@dev"

Register the bundle in your AppKernel

new QPautrat\ReactjsPhpBundle\ReactjsPhpBundle()

Configuration

Add in your config.yml file

reactjs_php:
    library_path: path_to_reactjs_library
    app_path: path_to_app_components

Usage

Use helper with php engine

<?php echo $view['reactjs']->renderMarkup('Component', array('foo' => 'bar')) ?>
<?php echo $view['reactjs']->renderJS('Component', '#dom_element', array('foo' => 'bar')) ?>

Or you can use our twig extension as well

{{ 'Component'|reactjs_render_markup({'foo':'bar'}) }}
{{ 'Component'|reactjs_render_js('#component', {'foo':'bar'}) }}

Demo

We provide a small demo application in another repository, living in a docker container, that you can use to test.

License

This bundle is available under the MIT License