Download the PHP package webiik/ssr without Composer
On this page you can find all versions of the php package webiik/ssr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package ssr
Short Description Server-side rendering of javascript UI components from PHP.
License MIT
Homepage https://www.webiik.com
Informations about the package ssr
SSR
Server-side rendering of javascript UI components from PHP. Out of the box, it supports React, however you can add any JS UI library.
Prerequisites
Supports
JS engines:
UI libraries:
- React
- Custom UI library.
Step-by-step Example
This example uses Webpack to bundle JS. You can use your favorite JS bundler.
-
Create the
MyTest
folder with the following file structure. -
Inside
MyTest
folder install all necessary packages. -
Create a component.
Edit
meow.jsx
to: -
Register the component.
Edit
index.js
to: -
Configure Webpack.
Edit
webpack.config.js
to: -
Bundle
index.js
tobuild/index.js
. Remember,build/index.js
MUST contain all code dependencies required to render the component with javascript. -
Render the component from PHP.
Edit
index.php
to:
Cache
You can use cache to store rendered components.
Custom UI library
SSR supports React out of the box, however, you can add support for your favorite UI library.
-
JS - Create a component registrar. Use registerReactComponent.tsx as template. The purpose of component registrar is to register function that renders component on a server and client.
-
PHP - Use method
setFwJsMask()
to tell SSR how to call the component registrar from step 1. -
PHP - Tell SSR that you want to use the component registrar from step 2.
or
If you need it. You can use more UI libraries at once.
Custom JS engine
The engine is a PHP class that processes JS and returns the result as a string. The engine MUST implement current engines to learn more.
- PHP - Create your engine.
- PHP - Tell SSR to use your engine.