-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.php
More file actions
36 lines (30 loc) · 724 Bytes
/
Copy pathapp.php
File metadata and controls
36 lines (30 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
require_once('vendor/autoload.php');
$rjs = new ReactJS(
// location of React's code
file_get_contents('build/react-bundle.js'),
// app code
file_get_contents('build/app.js')
);
$data = [
"time" => date("H:i:s")
];
$rjs->setComponent('App', $data);
?>
<!doctype html>
<html>
<head>
<title>React from PHP</title>
<link rel="stylesheet" href="./public/app.css">
</head>
<body>
<div id="app"><?php echo $rjs->getMarkup(); ?></div>
<!-- load react and app code -->
<script src="build/react-bundle.min.js"></script>
<script src="build/app.js"></script>
<!-- client-side render -->
<script>
<?php echo $rjs->getJS('#app', "GLOB"); ?>
</script>
</body>
</html>