New in Symplify 5: Create, Merge and Split Monorepo with 1 Command
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.
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
composer.json as you know it for most sections. But to manage
autoload-dev sections use only
/packages/second-package/composer.json like they were standalone packages.
Extra - mostly-dev - dependencies are managed by
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
You don't have to run this command manually since it's included in the next one.
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'
data_to_append section is for. These packages and versions will be added to
Btw, all packages are nicely sorted by name so you always find them quickly.
Let's do the split! Wait, do you even want to split packages into separate repositories? If so:
It's all prepared in config:
parameters: # for "split" command directories_to_repositories: packages/first-package: '[email protected]:your-monorepo/first-package.git' packages/secnod-package: '[email protected]:your-monorepo/second-package.git'
This step is optional. Most people use only
merge command at the start.
Discover other commands:
README for detail usage and tricks.
❤️️ Do you like what I write about? Or do you hate it but enjoy discussion? 😠
You can support my writing by throwing a couple bucks at my Patreon