定制 ontariotechu/xmodule 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ontariotechu/xmodule

Composer 安装命令:

composer require ontariotechu/xmodule

包简介

Utility classes for easily and consistently scaffolding API endpoints for Modo Labs XModule

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

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.

统计信息

  • 总下载量: 189
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固