enhance-dev/ssr
Composer 安装命令:
composer require enhance-dev/ssr
包简介
A PHP library for server-side rendering with Enhance
README 文档
README
A library for server rendering web components in PHP that is compatible with Enhance SSR (Enhance.dev).
Runtime: WASM or native PHP
This package includes both a WASM and native PHP version of enhance ssr. The WASM version allows component definitions written in JavaScript, but has specific requirements for the hosting environment that may be challenging. The examples directory includes examples of both versions.
Install
This package can be managed and installed with Composer:
composer require enhance-dev/ssr
The Extism dependency currently requires "minimum-stability":"dev" in the composer.json file.
Run Examples
To run the native and WASM examples run composer serve-native or composer serve-wasm respectively.
Usage:
See usage examples for native PHP and WASM in the examples directory.
Native PHP
<?php require "../../../vendor/autoload.php"; use Enhance\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;
WASM
<?php require "../../../vendor/autoload.php"; use Enhance\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";
Install Extism Runtime Dependency (for WASM only)
For the WASM version there are additional requirements. For this library, you first need to install the Extism Runtime by following the instructions in the PHP SDK Repository.
Acknowledgements
Thank you @mariohamann for prototyping a PHP example in using Extism https://github.com/mariohamann/enhance-ssr-wasm/tree/experiment/extism.
enhance-dev/ssr 适用场景与选型建议
enhance-dev/ssr 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 23, 最近一次更新时间为 2024 年 04 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 enhance-dev/ssr 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 enhance-dev/ssr 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2024-04-11