PHPackages                             lukecarrier/moodle-componentmgr - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. lukecarrier/moodle-componentmgr

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

lukecarrier/moodle-componentmgr
===============================

A package manager for Moodle components

v0.5.0(8y ago)14141[11 issues](https://github.com/LukeCarrier/moodle-componentmgr/issues)GPL-3.0+PHPPHP &gt;= 5.6.0

Since Jan 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/LukeCarrier/moodle-componentmgr)[ Packagist](https://packagist.org/packages/lukecarrier/moodle-componentmgr)[ Docs](https://github.com/LukeCarrier/moodle-componentmgr)[ RSS](/packages/lukecarrier-moodle-componentmgr/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (15)Versions (11)Used By (0)

Component Manager
=================

[](#component-manager)

[![Travis](https://camo.githubusercontent.com/c0ce053853405387d23a76b0b7adb6a68de5d0e812923b3803503d7cb9c26ea0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4c756b65436172726965722f6d6f6f646c652d636f6d706f6e656e746d67722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/LukeCarrier/moodle-componentmgr)[![Code Climate](https://camo.githubusercontent.com/a792068d0498a2ed0f43197487373d26419a0adb68d81d1c24314ce4f9e4cbf9/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f4c756b65436172726965722f6d6f6f646c652d636f6d706f6e656e746d67722e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/LukeCarrier/moodle-componentmgr)[![Scrutinizer](https://camo.githubusercontent.com/1d3ede46c2d70c8bb77218323889aed019147e429fccd67f58b712cd0947246a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f4c756b65436172726965722f6d6f6f646c652d636f6d706f6e656e746d67722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/LukeCarrier/moodle-componentmgr/)[![Scrutinizer Coverage](https://camo.githubusercontent.com/ed1e1ca88dcae8a6dfbb60a55e39426081147f722f2d064e504cf769b532a6dd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f4c756b65436172726965722f6d6f6f646c652d636f6d706f6e656e746d67722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/LukeCarrier/moodle-componentmgr/)[![Packagist](https://camo.githubusercontent.com/af095802a2c59ed32248fa8c67b2ae6822d6f503882d44d7aee9da7cb1871c84/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c756b65636172726965722f6d6f6f646c652d636f6d706f6e656e746d67722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lukecarrier/moodle-componentmgr)[![FOSSA Status](https://camo.githubusercontent.com/d51847f931f968bcf2365258efccd1ea7b1701889efc1bfb8ca06016b3c1aa69/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f67697425324268747470732533412532462532466769746875622e636f6d2532464c756b65436172726965722532466d6f6f646c652d636f6d706f6e656e746d67722e7376673f747970653d736869656c64)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FLukeCarrier%2Fmoodle-componentmgr?ref=badge_shield)

Component Manager is a tool to assist with the packaging and management of Moodle-based learning environments.

---

Key concepts
------------

[](#key-concepts)

For the sales pitch, see the [presentation](https://www.youtube.com/watch?v=1yspa9o-fMA) and [slides](https://docs.google.com/presentation/d/1SR-VWrZBAwlWMBrHzD5zCo1Lhz-4noeidOJJNbBYFyI/edit?usp=sharing).

- *Package repositories* contain metadata about components. This metadata describes the components themselves and contains information about available versions of the plugin as well as sources to obtain them.
- *Component sources* describe possible locations to obtain components in either source or distribution form, and are assembled based upon data provided by package repositories.
- *Package sources* define strategies that can be used to obtain components from specific types of sources (e.g. version control systems, archive files downloaded from repositories).
- *Version control* implementations allow us to download and checkout specific versions of components from a range of different sources.

License
-------

[](#license)

Component Manager is released under the terms of the GPL v3. This is the same license as the core Moodle distribution.

[![FOSSA Status](https://camo.githubusercontent.com/9c2b6ec6aec1cbf9b228b800877d7b0b65dd98480943b19b5acb07a56c6df200/68747470733a2f2f6170702e666f7373612e696f2f6170692f70726f6a656374732f67697425324268747470732533412532462532466769746875622e636f6d2532464c756b65436172726965722532466d6f6f646c652d636f6d706f6e656e746d67722e7376673f747970653d6c61726765)](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2FLukeCarrier%2Fmoodle-componentmgr?ref=badge_large)

Requirements
------------

[](#requirements)

- PHP &gt;= 5.6
- Moodle &gt;= 2.7

Installation
------------

[](#installation)

Component Manager can be installed in various different ways, each appropriate for different use cases.

### Globally, via CGR (recommended)

[](#globally-via-cgr-recommended)

[CGR](https://github.com/consolidation/cgr) provides a safe alternative to globally requiring packages by sandboxing individual packages and their dependencies. This approach is recommended for most users.

1. Globally require CGR with `composer global require consolidation/cgr`.
2. Install Component Manager with `cgr lukecarrier/moodle-componentmgr`.

### Globally, via Composer

[](#globally-via-composer)

In this configuration, Component Manager is accessible on the shell (via your preferred `$SHELL` or Command Prompt), and the same installation is used across all of your projects. This approach is not recommended for Component Manager, as globally requiring packages with dependencies is likely to lead to dependency problems.

1. Install PHP for your platform.
2. Install Composer as per their [Getting Started](https://getcomposer.org/doc/00-intro.md) guide. We assume that you can launch `composer` on your shell.
3. Ensure Composer's global `vendor/bin` directory is on your `PATH`:

- On Linux/Mac, it's probably `$HOME/.composer/vendor/bin`
- On Windows, this is usually `%APPDATA%\Roaming\Composer\vendor\bin`

4. Install Component Manager globally with `composer global require lukecarrier/moodle-componentmgr`

### Locally, via Composer

[](#locally-via-composer)

In this configuration, Component Manager isn't accessible globally from the shell, so `package` operations can only be performed by manually adding the `bin` directory to your `PATH` or specifying the full path to the `componentmgr` executable.

```
$ composer require lukecarrier/moodle-componentmgr

```

### Manually (ideal for development)

[](#manually-ideal-for-development)

Component Manager can also be run in-place. This is recommended for performing development within Component Manager itself.

1. Clone this repository somewhere on your disk.
2. Ensure our `bin` directory is on your system `PATH`.
3. Run `composer install` within the repository to obtain the dependencies.

`install` usage
---------------

[](#install-usage)

In this mode, Component Manager is launched from the root directory of a Moodle site. It reads the project and project lock files from the present working directory, then deploys the specified components from the specified package repositories. This mode is designed for use in development environments.

Create a `componentmgr.json` file in the root of your Moodle project. This file, referred to as the project file or manifest, contains a summary of all of the plugins required for installation of your platform and associated versions.

In order for Component Manager to source your plugins, you'll need to explicitly specify which locations to treat as package repositories. These are declared in the `"packageRepositories"` section of your project file, indexed by an alias you'll use to refer to them from component entries later. At a minimum, they'll consist of a `"type"`, but additional options might be required for other implementations.

To use the [Moodle.org/plugins repository](https://moodle.org/plugins), you'll need the following stanza in your project file:

```
{
    "packageRepositories":
    {
        "moodle":
        {
            "type": "Moodle"
        }
    }
}
```

Other package repositories are available, allowing deployment from corporate version control and distribution systems. At the moment:

- `"Filesystem"` can be used to lookup components on the local disk.
- `"Git"` lets you directly specify local and remote Git repository URIs.
- `"Github"` allows Component Manager to query GitHub.com repositories, specified with the `"repository"` property of each component. To enable a greater API rate limit, consider setting the `token` field to a token generated with the `public_repo` scope [here](https://github.com/settings/tokens/new?description=componentmgr&scopes=public_repo).
- `"Moodle"` allows access to the [Moodle.org/plugins](https://moodle.org/plugins/) repository, versioning plugins by either their plugin version (`YYYYMMDDXX`) or release name.
- `"Stash"` allows access to individual projects within a Bitbucket Server (formerly Stash) deployment. Project names should match component names and components are versioned via [Git references](https://git-scm.com/book/en/v2/Git-Internals-Git-References).

You're now ready to start declaring components. Components are declared in the `"components"` section of your project file, indexed by their [frankenstyle](https://docs.moodle.org/dev/Frankenstyle) component names. Each component object has three keys:

- The `"version"` key specifies either a plugin version or release name, both consistent with Moodle's [`version.php`](https://docs.moodle.org/dev/version.php) files.
- The `"packageRepository"` key specifies the package repository, declared in the `"packageRepositories"` section of the project file, which should be used used as the source of data for this component.
- Finally, the `"packageSource"` key specifies which type of component source to obtain. At the moment, the following sources are available:
    - `"Directory"` sources components from the specified filesystem location.
    - `"Git"` sources components from the specified Git reference.
    - `"Zip"` sources components via zip archives from remote locations.

An example to install [version 0.4.0](https://moodle.org/plugins/pluginversion.php?id=7567) of the [`local_cpd`](https://moodle.org/plugins/view/local_cpd) plugin from the zipped distributions on Moodle.org would look like the following:

```
{
    "components": {
        "local_cpd": {
            "version": "0.4.0",
            "packageRepository": "moodle",
            "packageSource": "Zip"
        }
    }
}
```

Bringing this altogether gives us a `componentmgr.json` file that looks something like the following:

```
{
    "components": {
        "local_cpd": {
            "version": "0.4.0",
            "packageRepository": "moodle",
            "packageSource": "Zip"
        }
    },

    "packageRepositories": {
        "moodle": {
            "type": "Moodle"
        }
    }
}
```

We're now ready to install our plugins. First, we'll get Component Manager to fetch metadata about all of the available components from our configured package repositories. It'll cache this data to save traffic and time later:

```
$ componentmgr refresh

```

With this data now ready, we can fetch our plugins by switching to the directory containing our Moodle installation and issuing the install command:

```
$ cd ~/Sites/LukeCarrier-Moodle
$ componentmgr install

```

Now we can choose to perform the plugins' database upgrades via either the Moodle Notifications page under Site administration, or the handy CLI script:

```
$ php admin/cli/upgrade.php

```

`package` usage
---------------

[](#package-usage)

In this mode, Component Manager can be launched from any arbitrary location, and it generates a package containing an entire Moodle site. The version of Moodle and related components to deploy is determined from a property in the project file. This mode is designed for use in CI and production environments.

To use Component Manager to package Moodle releases, you'll first need to determine an appropriate expression for your desired Moodle version. You're advised to use a branch here, as Component Manager will pin the exact Moodle version in the project lock file during installation.

You'll then need to choose an installation source:

- `"zip"` is the recommended option. Component Manager will obtain the specified release archive from `download.moodle.org`. These releases will have passed Moodle HQ's testing process.
- `"git"` should be used for more advanced configurations.

The support for the different version formats across the different installation sources is as follows:

Version formatBehaviourGitZip`2.7`Latest available release in branch✔✔`2.7+`Latest available release in branch with fixes✔✔`2.7.10`Specific release version✔✔`2.7.10+`Specific release version with fixes✔✘`2014051210`Specific release version✔✘`2014051210.05`Specific release version with fixes✔✘Bringing this together, you should place the following stanza into your project file:

```
{
    "moodle": {
        "version": "2.7+",
        "source": "zip"
    }
}
```

Packages can be generated in the following formats:

- `"Directory"` simply copies the packaged files to the specified directory.
- `"WebDeploy"` packages are generated using Microsoft's `msdeploy`utility and are well suited to deployment on Windows.
- `"ZipArchive"` packages are suited to deployment everywhere.

For example, to generate a generic zip ball containing your Moodle site, you can run the following command:

```
$ componentmgr package --package-format=ZipArchive \
                       --package-destination=/tmp/moodle.zip \
                       --project-file=moodle.org.json

```

Component lifecycle
-------------------

[](#component-lifecycle)

Component Manager allows components to run scripts at specific stages of the installation and packaging processes. These are:

- `build` -- fired once all components have been installed to the site, intended for use to install client-side dependencies via package managers and perform any building/minification of assets.

To take advantage of this feature, create a `componentmgr.comnponent.json` in the top level of your repository with the following content:

```
{
    "scripts": {
        "build": "your command (e.g. npm install && npm run gulp)"
    }
}
```

You can verify that your build steps function as expected without having to perform an installation or package operation with the `run-script` command:

```
$ cd local/componentmgrtest/
$ componentmgr run-script build

```

Development
-----------

[](#development)

Milestones are prepared from GitHub issues and maintained using [HuBoard](https://huboard.com/LukeCarrier/moodle-componentmgr).

To get a change into Component Manager:

1. Fork a new branch off of `develop` if it's a feature for the next major release, or off `master` if it's a bug fix.
2. Make your changes, and commit them. Try to be mindful of commit messages, and don't be afraid of spreading particularly large or complex changes across commits.
3. Submit a pull request.

Testing
-------

[](#testing)

Component Manager is both unit and integration tested.

### Integration tests

[](#integration-tests)

Integration tests are written in [ServerSpec](http://serverspec.org/), with [Test Kitchen](http://kitchen.ci/) configured to run them in a clean environment using the [Docker](https://www.docker.com/) driver.

To get started, install Kitchen and the necessary dependencies with [Bundler](http://bundler.io/):

```
$ bundle install

```

Then run the tests:

```
$ bundle exec kitchen test

```

### Unit tests

[](#unit-tests)

Unit tests are written with [PHPUnit](https://phpunit.de/). Ensure that Composer development dependencies are installed, then run the tests:

```
$ vendor/bin/phpunit

```

This will generate various coverage and pass/fail reports in the `tmp`directory.

Note that a portion of the tests for the platform support components will fail on platforms they're not designed for. To exclude them, use PHPUnit's `--exclude-group` switch on the following groups as appropriate:

- `platform-linux`
- `platform-windows`

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.7% 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 ~118 days

Recently: every ~171 days

Total

7

Last Release

3042d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.5.0

v0.2.0PHP &gt;= 5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ee94b9f6ec2363fac1285fa3bff4d9c0aef4ad30369dc42b4822f5eb6f32eef?d=identicon)[LukeCarrier](/maintainers/LukeCarrier)

---

Top Contributors

[![LukeCarrier](https://avatars.githubusercontent.com/u/597015?v=4)](https://github.com/LukeCarrier "LukeCarrier (356 commits)")[![fossabot](https://avatars.githubusercontent.com/u/29791463?v=4)](https://github.com/fossabot "fossabot (1 commits)")

---

Tags

pluginpackagemoodle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lukecarrier-moodle-componentmgr/health.svg)

```
[![Health](https://phpackages.com/badges/lukecarrier-moodle-componentmgr/health.svg)](https://phpackages.com/packages/lukecarrier-moodle-componentmgr)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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