php-monorepo-builder
monorepo-builder
A set of tools for managing PHP monorepos: merging composer.json files, validating package versions, releasing with automation, and more.
Repository: symplify/monorepo-builder
Package: monorepo-php/monorepo (via Packagist)
Language: PHP 8.2+
License: MIT License
Latest Release: 12.5.2 (2026-03-26)
When to Use This Skill
Use this skill when you need to:
- Set up a new PHP monorepo — scaffolding directory structure, initial
monorepo-builder.phpconfig - Merge
composer.jsonfiles — aggregate dependencies from all packages into the rootcomposer.json - Validate version consistency — ensure all inter-package dependencies use matching version constraints
- Automate releases — bump versions, tag releases, push tags across all packages in one command
- Manage package discovery — configure which directories are scanned for packages, and which to exclude
- Append or remove data after merge — add shared dev dependencies, remove per-package-only entries
- Troubleshoot merge issues — composer section ordering, dropped custom keys,
readmeproperty loss (fixed in 12.5.0) - Configure release workers — customize the sequence of steps that run during a release
Quick Reference
Installation
composer require monorepo-php/monorepo --dev
Requires PHP 8.2+. For PHP 8.1, use symplify/monorepo-builder:^11.2 (no longer maintained).
Initialize a New Monorepo
vendor/bin/monorepo-builder init
Generates a basic monorepo structure and a starter monorepo-builder.php config at your project root.
Core Commands
| Command | Description |
|---|---|
vendor/bin/monorepo-builder merge |
Merge all package composer.json into root |
vendor/bin/monorepo-builder validate |
Check that inter-package versions are consistent |
vendor/bin/monorepo-builder propagate |
Push root dependency versions back into package composer.json files |
vendor/bin/monorepo-builder bump-interdependency <version> |
Update mutual package constraints to one target version |
vendor/bin/monorepo-builder package-alias |
Update branch-alias across package composer.json files |
vendor/bin/monorepo-builder localize-composer-paths |
Swap mutual package paths to local paths for pre-split testing |
vendor/bin/monorepo-builder release <version> |
Tag and release a new version across all packages |
vendor/bin/monorepo-builder init |
Scaffold a new monorepo structure |
Configuration: Package Directories
All configuration lives in monorepo-builder.php at the project root.
use Symplify\MonorepoBuilder\Config\MBConfig;
return static function (MBConfig $mbConfig): void {
// Scan multiple directories for packages
$mbConfig->packageDirectories([
__DIR__ . '/packages',
__DIR__ . '/projects',
]);
// Exclude specific packages from discovery
$mbConfig->packageDirectoriesExcludes([
__DIR__ . '/packages/secret-package',
]);
};
Configuration: Merge — Append and Remove Data
use Symplify\MonorepoBuilder\ComposerJsonManipulator\ValueObject\ComposerJsonSection;
use Symplify\MonorepoBuilder\Config\MBConfig;
use Symplify\MonorepoBuilder\ValueObject\Option;
return static function (MBConfig $mbConfig): void {
// Add data to root composer.json after merge
$mbConfig->dataToAppend([
ComposerJsonSection::AUTOLOAD_DEV => [
'psr-4' => [
'Symplify\Tests\\' => 'tests',
],
],
ComposerJsonSection::REQUIRE_DEV => [
'phpstan/phpstan' => '^2.1',
],
]);
// Remove data from root composer.json after merge
$mbConfig->dataToRemove([
ComposerJsonSection::REQUIRE => [
// Version is irrelevant — removed by key
'phpunit/phpunit' => '*',
],
ComposerJsonSection::REPOSITORIES => [
Option::REMOVE_COMPLETELY,
],
]);
};
Note (12.5.0+):
dataToAppendnow supports arbitrary composer.json keys — no longer limited to 24 hardcoded sections.
Run a Merge
vendor/bin/monorepo-builder merge
Reads all composer.json files in discovered package directories and merges their dependencies into the root composer.json.
Release a New Version
vendor/bin/monorepo-builder release 1.2.0
Runs all configured release workers in sequence (bump versions, create tags, push, etc.).
Split Packages to Separate Repositories
Monorepo Builder does not handle package splitting itself. For split repos, pair it with symplify/github-action-monorepo-split in GitHub Actions.
Key Concepts
Package Discovery
By default, monorepo-builder scans ./packages for subdirectories containing a composer.json. You configure additional or alternative directories with packageDirectories(). Packages whose directory names contain tests may be excluded — see issue #59.
Merge Behaviour
The merge command aggregates require, require-dev, autoload, autoload-dev, and other sections from all discovered packages into the root composer.json. Since 12.5.0, custom/non-standard keys (e.g. scripts-aliases, abandoned, readme) are preserved during merge.
Release Workers
Release workers are discrete steps executed in sequence during a release. They can be customized or reordered. A known issue (#77) exists where SetNextMutualDependenciesReleaseWorker always increments the minor version — review worker ordering carefully.
Version Validation
The validate command checks that when package A depends on package B (both in the monorepo), the version constraint in A's composer.json matches the actual version of B. This prevents inter-package version drift.
Known Issues
Open Issues
| # | Summary |
|---|---|
| #90 | [Feature] Conventional Commit release support |
| #77 | SetNextMutualDependenciesReleaseWorker always updates minor version |
| #76 | No helper to import autoloader regardless of monorepo depth |
| #72 | Incompatible declaration in EventDispatcher.php |
| #69 | Composer install behaviour question |
| #59 | Packages with tests in name are always ignored |
| #25 | Interdependency version update fails for pre-release versions |
Recently Fixed (12.5.0 — 2026-02-13)
- Merge now preserves unknown/custom composer.json sections —
scripts-aliases,abandoned,readme, and any non-standard keys are no longer dropped (#105, #106, #71, #107) dataToAppendsupports arbitrary composer.json keys — no longer limited to 24 hardcoded sections (#105)
Recent Releases
| Version | Date | Highlights |
|---|---|---|
| 12.5.2 | 2026-03-26 | Allow sebastian/diff ^8 (#110) |
| 12.5.0 | 2026-02-13 | Preserve custom composer.json sections; arbitrary dataToAppend keys |
See references/releases.md for full release notes.
Reference Files
| File | Contents | Confidence |
|---|---|---|
references/README.md |
Full README: install, commands, configuration options, usage examples | Medium |
references/releases.md |
Release notes for all tagged versions (2 releases) | Medium |
references/issues.md |
All 34 GitHub issues — 7 open, 27 closed — with labels and dates | Medium |
references/file_structure.md |
Repository directory tree (813 items) | Medium |
Working with This Skill
Beginner
- Run
vendor/bin/monorepo-builder initto scaffold your monorepo. - Add packages under
packages/(each with its owncomposer.json). - Run
vendor/bin/monorepo-builder mergeto sync dependencies into root. - Check
references/README.mdfor full configuration options.
Intermediate
- Customize
monorepo-builder.phpto add multiple package directories and exclusions. - Use
dataToAppendto inject shared dev tooling (PHPStan, PHPUnit) into rootcomposer.json. - Use
dataToRemoveto strip per-package-only entries (e.g. local repositories) from the merged root. - Run
validatein CI to catch inter-package version drift early. - Use
propagateorbump-interdependencywhen root and package version constraints need to move together.
Advanced
- Configure and reorder release workers for custom release pipelines.
- Use
Option::REMOVE_COMPLETELYto drop entire sections (e.g.repositories) after merge. - Be aware of issue #77 when using
SetNextMutualDependenciesReleaseWorker— it may bump the minor version unexpectedly. - For pre-release versions (alpha/beta/RC), see issue #25 before relying on automatic interdependency updates.
- Use branch-aware tag validation if you maintain multiple active major version lines.
Source: GitHub repository symplify/monorepo-builder | Last updated: 2026-04-11
More from aaronflorey/agent-skills
amber-lang
Write, debug, and explain Amber code, the `amber` language that compiles `.ab` files to Bash. Use this skill when the user asks to write an Amber script, convert Bash to Amber, compile Amber to Bash, debug Amber syntax or type errors, or asks about Amber 0.5.1-alpha syntax, functions, types, error handling, the standard library, or the `amber` CLI.
26go-cobra
Write, scaffold, and debug Go CLI applications with `github.com/spf13/cobra`. Use this skill whenever the user mentions Cobra, `cobra.Command`, a Go command-line app, subcommands, persistent or local flags, required flags, argument validation, shell completions, generated docs, or wants to build or refactor a cobra-based CLI.
24laravel-actions
Write, scaffold, explain, and refactor code using the `lorisleiva/laravel-actions` package. Use this skill whenever the user mentions Laravel Actions, `AsAction`, `php artisan make:action`, action classes, converting a controller, job, listener, or command into an action, dispatching an action as a job, using an action as a controller or listener, or adding validation, authorization, testing, or mocking around an action.
24num30-config
Write, debug, and explain Go configuration code using `github.com/num30/config`. Use this skill when the user mentions `num30/config`, wants config structs, file plus env plus CLI flag loading, validation, config watching, precedence rules, or asks how to integrate the num30/config package into a Go application.
22pelican-panel-plugins
Write, scaffold, explain, and debug plugins for the Pelican gaming panel. Use this skill whenever the user mentions Pelican plugins, extending Pelican, FilamentPHP resources or pages for Pelican, plugin service providers, custom permissions, plugin settings, routes, models, widgets, or asks how to add new functionality to the Pelican panel.
21go-viper
Write, debug, and explain Go configuration code with `github.com/spf13/viper`. Use this skill whenever the user mentions Viper, `viper`, config structs, reading config from files plus env vars plus flags, Cobra or `pflag` integration, unmarshaling into structs, env key replacers, config precedence, config watching, or a clean Viper bootstrap.
20