PHPackages                             ontariotechu/xmodule - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ontariotechu/xmodule

ActiveLibrary[API Development](/categories/api)

ontariotechu/xmodule
====================

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

v1.2.6(6y ago)2189[2 PRs](https://github.com/uoitwebteam/xmodule/pulls)MITPHPPHP &gt;=7.0.0

Since May 16Pushed 4y agoCompare

[ Source](https://github.com/uoitwebteam/xmodule)[ Packagist](https://packagist.org/packages/ontariotechu/xmodule)[ Docs](https://github.com/uoitwebteam/xmodule)[ RSS](/packages/ontariotechu-xmodule/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (18)Used By (0)

XModule
=======

[](#xmodule)

[![Latest Stable Version](https://camo.githubusercontent.com/0e137723099969d09dfc1c12efdc76b3137ea6b62cab55e4f4251b742dd72b06/68747470733a2f2f706f7365722e707567782e6f72672f6f6e746172696f74656368752f786d6f64756c652f762f737461626c652e737667)](https://packagist.org/packages/ontariotechu/xmodule) [![Total Downloads](https://camo.githubusercontent.com/66d0a2244c54985a59e991e4aba7b9dd894dd1af7fd390fe0136415c0f89aba0/68747470733a2f2f706f7365722e707567782e6f72672f6f6e746172696f74656368752f786d6f64756c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/ontariotechu/xmodule)[![Latest Unstable Version](https://camo.githubusercontent.com/5ccaa2bb74ea2d68d33fd2596590c7348c79c13a8155f7c94cdddc31b83dbe6e/68747470733a2f2f706f7365722e707567782e6f72672f6f6e746172696f74656368752f786d6f64756c652f762f756e737461626c652e737667)](https://packagist.org/packages/ontariotechu/xmodule) [![License](https://camo.githubusercontent.com/daed8d046047f895cfdc51a0a39ae8c050b82f8b2417915b5b14d99446cb6464/68747470733a2f2f706f7365722e707567782e6f72672f6f6e746172696f74656368752f786d6f64756c652f6c6963656e73652e737667)](https://packagist.org/packages/ontariotechu/xmodule)

PHP library for easily and consistently scaffolding REST API endpoints for [Modo Labs](https://www.modolabs.com/)' **XModule** feature.

This library provides a suite of PHP classes that directly mirror Modo's [collection of XModule elements](https://xmodule-docs.modolabs.net). 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
============

[](#requirements)

- PHP &gt;= 7.0.0

Installation
============

[](#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
=====

[](#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:
-------

[](#result)

```
{
  "metadata": {
    "version": "1"
  },
  "content": [
    {
      "elementType": "buttonContainer",
      "id": "link_buttons",
      "buttons": [
        {
          "elementType": "linkButton",
          "title": "Click here",
          "link": {
            "relativePath": "./"
          }
        }
      ]
    }
  ]
}
```

Documentation
=============

[](#documentation)

**General usage how-tos can be found in the [wiki of this repository](../../wiki). The pages of the wiki are also presented in a single document inside [usage.md](/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`](/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
=======

[](#credits)

- [**Modo Labs**](https://www.modolabs.com/) created XModule and the mobile application software it is used in. All trademarks belong to them.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

14

Last Release

2516d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.2.0

v1.0.1PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b105d9b91e3313f7d50e5c4bbea2a2e9cad1709366819b98911a841cdd420f19?d=identicon)[otwebteam](/maintainers/otwebteam)

---

Top Contributors

[![wosevision](https://avatars.githubusercontent.com/u/10436894?v=4)](https://github.com/wosevision "wosevision (79 commits)")

### Embed Badge

![Health badge](/badges/ontariotechu-xmodule/health.svg)

```
[![Health](https://phpackages.com/badges/ontariotechu-xmodule/health.svg)](https://phpackages.com/packages/ontariotechu-xmodule)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
