PHPackages                             starbug/composer-modules-plugin - 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. starbug/composer-modules-plugin

ActiveComposer-plugin

starbug/composer-modules-plugin
===============================

A composer plugin for generating a module list.

v1.0.0(4mo ago)14.7k↓50%1GPL-3.0-or-laterPHP

Since Jan 13Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/cogentParadigm/composer-modules-plugin)[ Packagist](https://packagist.org/packages/starbug/composer-modules-plugin)[ RSS](/packages/starbug-composer-modules-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (1)

Composer Modules Plugin
=======================

[](#composer-modules-plugin)

A composer plugin which dumps a topologically sorted list of packages of specific types into vendor/modules.php.

This allows a framework module system to be built on top of composer. Suppose you want to create a module system. You would probably want some way for modules to declare themselves and to allow modules to declare other modules as dependecies. Well composer already does this in a more rubust way than most framework developers are likely to implement. If we want to build a module system on top of composer, we really just need a way to pull out a list of the relevant packages, put them in order, and perhaps grab some configuration data from them.

Usage
=====

[](#usage)

First, pick a package type for your modules. We'll be using `starbug-module`, so a `composer.json` for such a a module would look like this.

```
{
  "name": "starbug/my-module",
  "type": "starbug-module"
}
```

To use this as a module type, we need to do two things in our root package.

1. Require `starbug/composer-modules-plugin`
2. Add the `modules-plugin` key under `extra` mapping composer package types to your own module types.

Here's a `composer.json` which includes both, and also requires our example module above (`starbug/my-module`).

```
{
  "name": "starbug/my-project",
  "type": "project",
  "require": {
    "starbug/composer-modules-plugin": "^0.8",
    "starbug/my-module": "^1.0"
  },
  "extra": {
    "modules-plugin": {
      "types": {
        "starbug-module": "module"
      }
    }
  }
}
```

Given this package definition above, when you run `composer install` or `composer update`, a file will be written to `vendor/modules.php` with the contents below.

```
