Download the PHP package koriym/baracoa without Composer
On this page you can find all versions of the php package koriym/baracoa. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download koriym/baracoa
More information about koriym/baracoa
Files in koriym/baracoa
Package baracoa
Short Description A JavaScript server side rendering interface
License MIT
Informations about the package baracoa
Baracoa
A JavaScript server side rendering interface
Bracoa provides a simple interface for JavaScript server side rendering in PHP.
Prerequisites
- php7.1
- V8Js
Installation
Basic
In a JS renderer application, implement render
function which takes parameter(s) and return html string.
Call the render()
method with JS app name and values to assign to redner.
In this example, you need to place min.bundle.js
JS file in $jsDir
directory.
Every page needs own JS view application which is bundled single file by bundler tool like webpack.
Typical entry file is like following code.
In next section we see the example of Redux with React applicaiton example.
Redux React
The Server Side
Inject an initial component HTML and initial state into a template to be rendered on the client side.
To pass along the state, we add a <script>
tag that will attach preloadedState
to window.__PRELOADED_STATE__
.
The preloadedState will then be available on the client side by accessing window.__PRELOADED_STATE__
.
We also include our bundle file for the client-side application via a <script>
tag.
This is whatever output your bundling tool provides for your client entry point.
render.js
render()
method can pass second parameter as SSR meta data which is only available in server side rendering. Typically this value is used in <header>
such as for OGP.
The Client Side
We need to do is grab the initial state from window.__PRELOADED_STATE__
which is rendered in server side, and pass it to our createStore()
function as the initial state.
Performance boost
An external "snapshot" is saved to increase performance in each app with CacheBaracoa
.
Highly recommended in production site.
Consider internal snapshot for more performance.
See more detail in this blog post.
Run demo
min
handlebar
redux react
Install V8Js
OSX
edit php.ini
or add 'V8Js.ini'
JS UI Application Skeleton
UiSkeleton is a Javascript UI application skeleton with hot module loader, browsersync, test, lint and more for development.