-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
39 lines (37 loc) · 828 Bytes
/
index.php
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
37
38
<?php
$startTime = microtime(true);
$props = array();
$props["var"] = "server";
?>
<html>
<head>
<title>Preact-PHPv8js Example</title>
</head>
<body>
<div id="app">
<?php
$v8 = new V8Js();
try {
$react = [
file_get_contents("dist/bundle-server.js"),
'EntryPoint.render('.json_encode($props).');'
];
$v8->executeString(implode(PHP_EOL, $react), 'preact-on-server');
} catch (V8JsException $e) {
var_dump($e);
}
?>
</div>
</body>
<script src="dist/bundle-client.js"></script>
<script>
window.onload = function () {
EntryPoint.render_client({var: "client"});
};
</script>
<?php
$endTime = microtime(true);
$elapsed = $endTime - $startTime;
echo "Execution time : $elapsed seconds";
?>
</html>