ontariotechu/xmodule
Composer 安装命令:
composer require ontariotechu/xmodule
包简介
Utility classes for easily and consistently scaffolding API endpoints for Modo Labs XModule
README 文档
README
PHP library for easily and consistently scaffolding REST API endpoints for Modo Labs' XModule feature.
This library provides a suite of PHP classes that directly mirror Modo's collection of XModule elements. It aids in the creation of complex XModule layouts by removing the need for boilerplate JSON and ensuring all XModule pieces fit together seamlessly using object-oriented workflows and strongly-typed parameters.
After being built, scaffolded XModules can have their contents output in fully compliant JSON using only the json_encode result of a call to $xmodule->render().
Requirements
- PHP >= 7.0.0
Installation
$ composer require ontariotechu/xmodule:dev-master
Don't forget to include Composer's autoloader once at the beginning of your application:
require __DIR__ . '/vendor/autoload.php';
Usage
Import the needed components into your server application:
use \XModule\Base\XModule; use \XModule\Shared\Link; use \XModule\Constants\LinkType; use \XModule\ButtonContainer; use \XModule\LinkButton;
Use the components to build XModule structures:
/** * Create a new XModule */ $xmodule = new XModule(); /** * Create XModule elements */ $buttonContainer = new ButtonContainer(['id' => 'link_buttons']); $link = new Link('./', LinkType::RELATIVE_PATH); $button = new LinkButton('Click here', ['link' => $link]); /** * Attach your elements to each other and the XModule */ $buttonContainer->addButton($button) $xmodule->addContent($buttonContainer); /** * Render the output */ echo json_encode($xmodule->render());
Result:
{
"metadata": {
"version": "1"
},
"content": [
{
"elementType": "buttonContainer",
"id": "link_buttons",
"buttons": [
{
"elementType": "linkButton",
"title": "Click here",
"link": {
"relativePath": "./"
}
}
]
}
]
}
Documentation
General usage how-tos can be found in the wiki of this repository. The pages of the wiki are also presented in a single document inside usage.md for quick access.
Full class documentation is still pending, but in the meantime there are some very basic auto-generated docs that can be found in the /docs folder of this repository. Documentation can be regenerated or viewed using the included Composer scripts:
# regenerate $ composer run-script build-docs # view docs (http://0.0.0.0:8080) $ composer run-script docs
Credits
- Modo Labs created XModule and the mobile application software it is used in. All trademarks belong to them.
ontariotechu/xmodule 适用场景与选型建议
ontariotechu/xmodule 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 189 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 05 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ontariotechu/xmodule 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ontariotechu/xmodule 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 189
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-16