Removed the deprecated split
command. Use faster and reliable GitHub Action instead.
Do you want to create, validate and manage your monorepo like a pro? There is no science behind it, just a few routine steps that you need to repeat.
And now there is a tool that will handle these steps for you.
This package was initially released in Symplify 4.5, but it took some time to test in practice, remove WTFs and be sure it contains all people need.
Now there are 7 commands in total, but today we'll focus on the 4 most important ones.
First, install this package to an empty repository:
composer require symplify/monorepo-builder --dev
You'll run this command just once to create a monorepo in the empty repository.
vendor/bin/monorepo-builder init
It will prepare basic monorepo structure with 2 packages:
/packages
/first-package
/src
composer.json
/second-package
/src
composer.json
composer.json
monorepo-builder.yml # basic configuration
Use composer.json
as you know it for most sections. But to manage require
, require-dev
, autoload
and autoload-dev
sections use only /packages/first-package/composer.json
, /packages/second-package/composer.json
like they were standalone packages.
Extra - mostly-dev - dependencies are managed by monorepo-builder.yml
.
Is that unclear to you? Don't worry, you'll see how it works in merge
command below.
This command will tell you if your dependency versions are the same in every packages' composer.json
and in root composer.json
.
vendor/bin/monorepo-builder validate
You don't have to run this command manually since it's included in the next one.
composer.json
vendor/bin/monorepo-builder merge
Here you'll understand the magic from init
command. With merge
command, the Monorepo Builder will join all packages' composer.json
- after validation of course.
And what about extra dependencies like PHPUnit, coding standards and static analysis?
# monorepo-builder.yml
parameters:
# for "merge" command
data_to_append:
require-dev:
phpunit/phpunit: '^7.3'
That's what data_to_append
section is for. These packages and versions will be added to composer.json
.
Btw, all packages are nicely sorted by name so you always find them quickly.
Discover other commands:
vendor/bin/monorepo-builder
and read README
for detail usage and tricks.
Happy monorapping!
Do you learn from my contents or use open-souce packages like Rector every day?
Consider supporting it on GitHub Sponsors.
I'd really appreciate it!