Skip to content

Instantly share code, notes, and snippets.

@andikasputra
andikasputra / app-client.js
Created Aug 6, 2021
php server side rendering
View app-client.js
import app from './app';
app.$store.commit('setUser', {user: window.user})
app.$store.state.features = window.features
app.$mount('#app')
@andikasputra
andikasputra / index.php
Created Aug 6, 2021
php server side rendering
View index.php
<?php
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');
@andikasputra
andikasputra / app-server.js
Created Aug 6, 2021
php server side rendering
View app-server.js
import renderVueComponentToString from "vue-server-renderer/basic";
import app from "./app";
app.$store.commit("setUser", { user: context.user });
app.$store.state.features = context.features;
renderVueComponentToString(app, (err, html) => {
if (err) {
throw new Error(err);
}
@andikasputra
andikasputra / store.js
Created Aug 6, 2021
php server side rendering
View store.js
// js/store.js
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export function createStore() {
return new Vuex.Store({
state: {
@andikasputra
andikasputra / app.js
Created Aug 6, 2021
php server side rendering
View app.js
// js/app.js
import Vue from 'vue'
import App from '../components/App.vue'
import { createStore } from './store'
const store = createStore()
const app = new Vue({
store,
render: h => h(App)
@andikasputra
andikasputra / FeatureItem.vue
Created Aug 6, 2021
php server side rendering
View FeatureItem.vue
// FeatureItem.vue
<template>
<div v-bind:style="{ color: textColor }" v-on:click="toggleColor">
<h2>{{ feature.name }}</h2>
<p>{{ feature.description }}</p>
</div>
</template>
<script>
@andikasputra
andikasputra / App.vue
Created Aug 6, 2021
php server side rendering
View App.vue
// App.vue
<template>
<div id="app">
<sidebar title="Mantap"></sidebar>
<h1>{{message}}</h1>
<p class="good">{{count}}</p>
<button v-on:click="increment">increment</button>
<p>{{user.name}}</p>
<feature-item v-for="feature in features" :key="feature.id" :feature="feature"></feature-item>
@andikasputra
andikasputra / Sidebar.vue
Created Aug 6, 2021
php server side rendering
View Sidebar.vue
// Sidebar.vue
<template>
<div>
<h2>Ini sidebar</h2>
<p>title sidebar : {{ title }}</p>
</div>
</template>
<script>
View preferences.sql
SELECT
MAX(CASE WHEN (pref_name = 'smtp_host') THEN pref_value ELSE NULL END) AS smtp_host,
MAX(CASE WHEN (pref_name = 'smtp_port') THEN pref_value ELSE NULL END) AS smtp_port,
MAX(CASE WHEN (pref_name = 'smtp_user') THEN pref_value ELSE NULL END) AS smtp_user,
MAX(CASE WHEN (pref_name = 'smtp_pass') THEN pref_value ELSE NULL END) AS smtp_pass
FROM preferences
WHERE pref_group = 'email';
View form-ajax.html
<!DOCTYPE html>
<html lang="id" dir="ltr">
<head>
<meta charset="utf-8">
<title>AJAX Submit Form</title>
</head>
<body>
<form action="kirim-proses.php" method="post" id="formulir">
<input type="text" name="nama" placeholder="Nama Lengkap"><br>
<input type="email" name="email" placeholder="Email"><br>