drom/hypernova-php
Composer 安装命令:
composer require drom/hypernova-php
包简介
A PHP client for hypernova. https://github.com/airbnb/hypernova
关键字:
README 文档
README
PHP client for your Hypernova service.
Why Hypernova?
The broader question tends to be "how do I Server-Side Render my React app?" You may have this as a business requirement (e.g. SEO) or just want to give users the fastest initial render possible.
Assuming you have a PHP backend (why are you here, otherwise?), generally you will want to stand up a node.js service to do the rendering for you. You could try phpv8js but I believe it is contraindicated for production use at any scale. That's just my opinion, do your own research 😁
So then - write your own node.js service, or use one off the shelf. Writing your own node.js service isn't terrifically hard - you could reasonably stand up a thing that would render react components for you in ~20 lines of code. We personally went with hypernova because it's lightweight, pluggable (see the plugin system), performant (see the clever bytecode caching in createVM), and has nice client-side fallback behavior in case the service has issues.
Getting Started
composer require drom/hypernova-php
Make a Renderer:
use \WF\Hypernova\Renderer;
$renderer = new Renderer('http://localhost:3030/batch');
Give it some work:
$renderer->addJob('myViewId', ['name' => 'my_module_name', 'data' => ['some' => ['props']]]);
Optionally add a plugin or two (see plugin section):
$renderer->addPlugin($myPlugin);
$renderer->addPlugin($myOtherPlugin);
Then go get your rendered Response:
$response = $renderer->render();
echo $response->results['myViewId']->html;
Plugin API
This is how you customize client behavior. Common usecases include:
- Logging request metadata like performance timings
- Error logging
- Injecting/removing props
- Inlining stack traces in development environments
- Stopping requests to the service entirely, letting everything fall back to client rendering
Generally, you will want to implement some subset of the lifecycle hooks; maybe you
want onError handling but have no need for shouldSendRequest. For
developer convenience, you may extend \WF\Hypernova\Plugin\BasePlugin which
provides no-op implementations of all of the hooks.
See the js client docs for full descriptions of the available hooks.
Contributing:
Fork it, submit a PR.
Run tests:
composer test
Run phpstan
composer analyse
Run PHP fix
composer fix
drom/hypernova-php 适用场景与选型建议
drom/hypernova-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.74k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 10 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「react」 「hypernova」 「drom」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 drom/hypernova-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 drom/hypernova-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 drom/hypernova-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PHP client for hypernova. https://github.com/airbnb/hypernova
Async Reactive Postgres Driver for PHP (Non-blocking)
Laravel integration for blade-to-react
A simple, flexible Laravel package for adding polymorphic reactions to any model. React with any text: like, love, care, or anything you want.
Laravel PHP package to use Hypernova server-side rendering service.
This library tries to create a simple promise factory standard while waiting for a psr.
统计信息
- 总下载量: 11.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2021-10-07