PHPackages                             jeichorn/composer-monorepo-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. jeichorn/composer-monorepo-plugin

ActiveComposer-plugin

jeichorn/composer-monorepo-plugin
=================================

v0.12.6(8y ago)096.5k1MITPHP

Since Apr 10Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jeichorn/composer-monorepo-plugin)[ Packagist](https://packagist.org/packages/jeichorn/composer-monorepo-plugin)[ RSS](/packages/jeichorn-composer-monorepo-plugin/feed)WikiDiscussions master Synced today

READMEChangelog (6)Dependencies (4)Versions (31)Used By (0)

Composer Monorepo Plugin
========================

[](#composer-monorepo-plugin)

[![Build Status](https://camo.githubusercontent.com/00040cc986006a231f15db6fd8f75c0e6d6012bf9e0b7609bd4a8f6cb0aaa89a/68747470733a2f2f7472617669732d63692e6f72672f6a656963686f726e2f636f6d706f7365722d6d6f6e6f7265706f2d706c7567696e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jeichorn/composer-monorepo-plugin)

```
Note: this project is still experimental. Please provide feedback!

```

This plugin adds support for Monorepos when using Composer package manager. It introduces a maintainable approach to managing dependencies for multiple packages in a single repository, without losing the benefits of having explicit dependencies for each separate package.

Repositories managed with this plugin contain two kinds of packages:

1. Composer packages defined by a single global `composer.json` with all external dependencies at the root of the repository.
2. Many monorepo packages in sub-folders of the project, each with its own `monorepo.json`, a simplified `composer.json` file.

Dependencies in monorepos can be either a third party Composer package that is listed in the `composer.json` or a monorepo package contained in the project.

This plugins build step generates autoloaders with `vendor/autoload.php` files for each package with access to the explicitly specified dependencies only.

The following steps are performed by this plugin when building the autoloads:

1. It detects `monorepo.json` files in subdirectories excluding `vendor/` and marks them as roots of packages.
2. It then fetches all composer packages from the locally installed packages.
3. Finally for each package with `monorepo.json` it generates a `vendor/autoload.php` file using all the dependencies defined in that package from either other monorepo packages or regular Composer packages.

This plugin draws inspiration from Google [Blaze/Bazel](http://bazel.io/) and Facebook [Buck](http://facebook.github.io/buck/) implementing a single monolithic repository for whole projects/company. It's the missing piece for the monolithic repository workflow using PHP and Composer.

More details about reasoning on Gregory Szorc's blog:

- [On Monlithic Repositories](http://gregoryszorc.com/blog/2014/09/09/on-monolithic-repositories/)
- [Notes from Facebooks Developer Infrastructure at Scale F8 talk](http://gregoryszorc.com/blog/2015/03/28/notes-from-facebook's-developer-infrastructure-at-scale-f8-talk/)

Forked
------

[](#forked)

This is a forked version of the original , since it was no longer under active development

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

[](#installation)

Add the composer monorepo plugin to your root composer.json with:

```
$ composer require jeichorn/composer-monorepo-plugin

```

It will be automatically added as a Composer plugin.

Usage
-----

[](#usage)

Whenever Composer generates autoload files (during install, update or dump-autoload) it will find all sub-directories with `monorepo.json` files and generate sub-package autoloaders for them.

You can execute the autoload generation step for just the subpackages by calling:

```
$ composer monorepo:build

```

You create a `composer.json` file in the root of your project and use this single source of vendor libraries across all of your own packages.

This sounds counter-intuitive to the Composer approach at first, but it simplifies dependency management for a big project massively. Usually if you are using a composer.json per package, you have mass update sprees where you upate some basic library like "symfony/dependency-injection" in 10-20 packages or worse, have massively out of date packages and many different versions everywhere.

Then, each of your own package contains a `monorepo.json` using almost the same syntax as Composer:

```
{
    "deps": [
        "components/Foo",
        "vendor/symfony/symfony"
    ],
    "autoload": {
        "psr-0": {"Foo\\": "src/"}
    }
}

```

You can then run `composer dump-autoload` in the root directory next to composer.json and this plugin will detect all packages, generate a custom autoloader for each one by simulating `composer dump-autoload` as if a composer.json were present in the subdirectory.

This plugin will resolve all dependencies (without version constraints, because it is assumed the code is present in the correct versions in a monolithic repository).

Package names in `deps` are the relative directory names from the project root, *not* Composer package names.

You can just `require "vendor/autoload.php;` in every package as if you were using Composer. Only autoloads from the `monorepo.json` are included, which means all dependencies must be explicitly specified.

Configuration Schema monorepo.json
----------------------------------

[](#configuration-schema-monorepojson)

For each package in your monolithic repository you have to add `monorepo.json`that borrows from `composer.json` format. The following keys are usable:

- `autoload` - configures the autoload settings for the current package classes and files.
- `autoload-dev` - configures dev autoload requirements. Currently *always* evalauted.
- `deps` - configures the required dependencies in an array (no key-value pairs with versions) using the relative path to the project root directory as a package name.
- `deps-dev` - configures the required dev dependencies
- `bin-deploy-method` - symlink|copy, the standard method `symlink`, deploys vendor/bin scripts as symlinks to the parent vendor/bin. This breaks cases where you want to use the autoload ands its dependencies in a child repo. Copy copies the bins into vendor/bin in the child and then symlinks them so standard script discovery works.

Git Integration for Builds
--------------------------

[](#git-integration-for-builds)

In a monorepo, for every git commit range you want to know which components changed. You can test with the `git-changed?` command:

```
composer monorepo:git-changed? components/foo $TRAVIS_COMMIT_RANGE
if [ $? -eq 0 ]; then ant build fi
```

###  Health Score

34

↑

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 73.5% 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 ~29 days

Recently: every ~0 days

Total

28

Last Release

3204d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/51c9f0299b163ebf9be813ce0f81ae99a7b093144a42409dd3067c500319522e?d=identicon)[jeichorn](/maintainers/jeichorn)

---

Top Contributors

[![beberlei](https://avatars.githubusercontent.com/u/26936?v=4)](https://github.com/beberlei "beberlei (86 commits)")[![jeichorn](https://avatars.githubusercontent.com/u/122486?v=4)](https://github.com/jeichorn "jeichorn (15 commits)")[![boekkooi](https://avatars.githubusercontent.com/u/399895?v=4)](https://github.com/boekkooi "boekkooi (6 commits)")[![wjzijderveld](https://avatars.githubusercontent.com/u/450201?v=4)](https://github.com/wjzijderveld "wjzijderveld (4 commits)")[![orthographic-pedant](https://avatars.githubusercontent.com/u/14522744?v=4)](https://github.com/orthographic-pedant "orthographic-pedant (1 commits)")[![ribeiropaulor](https://avatars.githubusercontent.com/u/376830?v=4)](https://github.com/ribeiropaulor "ribeiropaulor (1 commits)")[![TiMESPLiNTER](https://avatars.githubusercontent.com/u/598854?v=4)](https://github.com/TiMESPLiNTER "TiMESPLiNTER (1 commits)")[![timglabisch](https://avatars.githubusercontent.com/u/689269?v=4)](https://github.com/timglabisch "timglabisch (1 commits)")[![timroberson](https://avatars.githubusercontent.com/u/913294?v=4)](https://github.com/timroberson "timroberson (1 commits)")[![cxj](https://avatars.githubusercontent.com/u/446131?v=4)](https://github.com/cxj "cxj (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jeichorn-composer-monorepo-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/jeichorn-composer-monorepo-plugin/health.svg)](https://phpackages.com/packages/jeichorn-composer-monorepo-plugin)
```

###  Alternatives

[symfony/flex

Composer plugin for Symfony

4.2k178.8M797](/packages/symfony-flex)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k302.1M1.1k](/packages/php-http-discovery)[composer/package-versions-deprecated

Composer plugin that provides efficient querying for installed package versions (no runtime IO)

1.5k188.8M198](/packages/composer-package-versions-deprecated)[composer/installers

A multi-framework Composer library installer

1.4k133.5M5.6k](/packages/composer-installers)[cweagans/composer-patches

Provides a way to patch Composer packages.

1.7k92.0M673](/packages/cweagans-composer-patches)[dealerdirect/phpcodesniffer-composer-installer

PHP\_CodeSniffer Standards Composer Installer Plugin

595158.0M1.6k](/packages/dealerdirect-phpcodesniffer-composer-installer)

PHPackages © 2026

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