nettpack/stage
Composer 安装命令:
composer require nettpack/stage
包简介
Nettpack stage js for Nette
README 文档
README
Nettpack staging is package for creating node components into Nette project.
Required
How to use:
-
First copy and paste content ./src/Config/stageJs.neon.dist into your config.neon in Nette project
-
Now use trait NettPack\Stage\Application\NettPackTrait into your base presenter file.
use NettpackTrait;
-
In layout.latte use this in head tag
{control nettpackLoader} -
In layout.latte use this in body tag on bottom line
{control nettpackControl}
How to use Application js class:
-
now you must study @nettpack/core line "example module (each module is webpack.config.js)" and search in webpack.config.js entry : {app: []} Entry point of this application.js like this:
if (module.hot) { module.hot.accept(); } import {App} from "Stage"; function importAll (r) { r.keys().forEach(r); } importAll(require.context('../', true, /\.(js|css|less|png|gif)$/)); $(document).ready(function () { App.run(); });
-
now you must study @nettpack/core line "How to insert another vendor package files into build collection"
-
Now you can create ComponentClass with sagas like this:
if (module.hot) { module.hot.accept(); } import {App, BaseComponent, SAGA_REDRAW_SNIPPET, Saga, Reducer} from "Stage" class TestControlComponent extends BaseComponent { initial() { super.initial(); this.installPlugins(); } @Saga(SAGA_REDRAW_SNIPPET) public installPlugins(action = null){ let target = document; if (action) { const {content} = action.payload; if (content) { target = content } } } } App.addComponent("TestControlComponent", TestControlComponent);
- Function initial start after App start function run();
- Annotation @Saga('TYPE_NAME')
- TYPE_NAME name of event
- function which may be run after event fire(to this action has been insert parameter action, this is Action object /vendor/nettpack/stage/src/Assets/Action.js)
- SAGA_REDRAW_SNIPPET - fire after redraw snippet action
-
If you want run saga onAnchor your component, you can use phpAnnotation.
use NettPack\Stage\Annotations as NP; /** * @NP\NettPack(snippetSagas={ * @NP\SnippetSaga(saga="SAGA_MY_COMPONENT", snippet="snippet--my-component") * }) */ class MyComponent extends Control { }
- After redrawControl my-component fire saga event SAGA_MY_COMPONENT and callback which has been on this event set
@Saga('SAGA_MY_COMPONENT') public myFunction(action) {}
-
If you want after Ajax action run another saga. To request data or parameters place parameter 'saga' and value 'name_of_saga_may_be_run_after_response'
const formData = new FormData(form[0]); formData.append('saga','name_of_saga_may_be_run_after_response'); $.ajax({ type: 'POST', url: form[0].action , data: formData, });
-
If you want into saga pass another custom parameter please use function
addSagasParameterimport {addSagasParameter} from "Stage"; const formData = new FormData(); addSagasParameter(formData, 'paramName', 'paramValue');
Reducers
-
BaseComponent contains function createReducer
- Reducer is for change current state in store inside your application thanks listening on sagas events.
-
Reducer example:
@Reducer('TEST') public testReducer(state = { myObject: { A: undefined, B: undefined, } }, action) { switch (action.type) { // Listening on TEST_SAGA and save new State from payload case 'TEST_SAGA': { const myObject = action.payload.myObject; return Object.assign({}, state, { myObject, }); } default: { return state; } } }
- And from App you can this reducer call
App.getStore().dispatch({ type: 'TEST_SAGA', payload: { myObject: { A: "TEST_A", B: "TEST_B", } }, });
- In devTools in your browser adminMode you can see 'prev state' and 'next state' change inside Test object (my testReducer):
nettpack/stage 适用场景与选型建议
nettpack/stage 是一款 基于 TypeScript 开发的 Composer 扩展包,目前已累计 234 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「stage」 「nettpack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nettpack/stage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nettpack/stage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nettpack/stage 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Stage File Proxy is a general solution for getting production files on a development server on demand.
Adds basic auth to your Silverstripe website the way it was intended (not just for pages, also for files).
Pipeline pattern implementation
Stage-based pipeline framework for batch ETL of record streams in Laravel — drivers, resolvers, per-stage stats.
Manipulates outgoing mails from Swiftmailer
Laravel package for presenting sites still in develompment.
统计信息
- 总下载量: 234
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-06-06