Skip to content

Instantly share code, notes, and snippets.

Created August 6, 2021 12:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
php server side rendering
require_once __DIR__ . '/../vendor/autoload.php';
use Spatie\Ssr\Renderer;
use Spatie\Ssr\Engines\Node;
$features = [
['id' => 1, 'name' => 'NVMe SSD Super Cepat', 'description' => '100% Enterprise NVMe SSD untuk performa website secepat kilat'],
['id' => 2, 'name' => 'Cloud Backup', 'description' => 'Backup harian ke Cloud menjamin keamanan data penting anda']
$engine = new Node("/home/andika/.nvm/versions/node/v14.17.1/bin/node", __DIR__.'/../dist');
$renderer = new Renderer($engine);
$res = $renderer
->context('user', ['name' => 'Andika'])
->context('features', $features)
<div id="app">
<?= $res ?>
<script defer src="../dist/app-client.js"></script>
window.user = <?= json_encode(['name' => 'Andika']) ?>;
window.features = <?= json_encode($features) ?>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment