PHP code example of enhance-dev / ssr
1. Go to this page and download the library: Download enhance-dev/ssr library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
enhance-dev / ssr example snippets
nhance\Enhancer;
use Enhance\Elements;
use Enhance\ShadyStyles;
$elementPath = __DIR__ . "/../resources";
$elements = new Elements($elementPath);
$scopeMyStyle = new ShadyStyles();
$enhance = new Enhancer([
"elements" => $elements,
"initialState" => [],
"styleTransforms" => [[$scopeMyStyle, "styleTransform"]],
"enhancedAttr" => true,
"bodyContent" => false,
]);
$htmlString = <<<HTMLDOC
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<my-header><h1>Hello World</h1></my-header>
</body>
</html>
HTMLDOC;
$output = $enhance->ssr($htmlString);
echo $output;
nhance\EnhanceWASM;
use Enhance\Elements;
$elementPath = "../resources";
$elements = new Elements($elementPath, ["wasm" => true]);
$enhance = new EnhanceWASM(["elements" => $elements->wasmElements]);
$input = [
"markup" => "<my-header>Hello World</my-header>",
"initialState" => [],
];
$output = $enhance->ssr($input);
$htmlDocument = $output->document;
echo $htmlDocument . "\n";