PHP code example of reactjs / react-php-v8js
1. Go to this page and download the library: Download reactjs/react-php-v8js library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reactjs / react-php-v8js example snippets
// the library
$react_source = file_get_contents('/path/to/build/react.js');
// all custom code concatenated
$app_source = file_get_contents('/path/to/custom/components.js');
$rjs = new ReactJS($react_source, $app_source);
$rjs->setComponent('MyComponent', array(
'any' => 1,
'props' => 2
)
);
/// ...
// print rendered markup
echo '<div id="here">' . $rjs->getMarkup() . '</div>';
/// ...
// load JavaScript somehow - concatenated, from CDN, etc
// including react.js and custom/components.js
// init client
echo '<script>' . $rjs->getJS("#here") . '</script>';
/// ...
// repeat setComponent(), getMarkup(), getJS() as necessary
// to render more components