Learn to manage a monorepo, a tool that helps to handle the complexity of large codebases by hosting all PHP packages in a single repository.
Learn to manage a monorepo, a tool that helps to handle the complexity of large codebases by hosting all PHP packages in a single repository.
When a PHP project gets big and complex, it becomes difficult to manage.
In this situation, we’d split the project into independent packages and use Composer to import all packages into the project. Then, different functionalities can be implemented and maintained by different teams and can be reused by other projects, too.
Composer uses the Packagist registry to distribute PHP packages. Packagist requires us to provide a repository URL when publishing a new package.
As a consequence, splitting a project into packages also affects how they are hosted: from a single repository hosting the whole code to a multitude of repositories to host the code for every package.
So we have solved the problem of managing the project’s code, but at the expense of creating a new problem: now we have to manage the hosting of the code.
Our packages will be versioned, and every version of the package will depend on some specific version of another package, which will itself depend on some other version of some other package, and so on.
This becomes a problem when submitting a pull request for your project; most likely, you will also need to modify the code in some package, so you need to create a new branch for that package and point to it in your composer.json
.
Then, if that package depends on some other package that must also be modified, you need to create a new branch for it and update the first package’s composer.json
to point to it.
And if that package depends on some other package… You get the point.
Then, once you approve the pull request, you need to undo all modifications in all composer.json
files to point to the newly published version of the package.
This all becomes so difficult to achieve that you may quite likely stop altogether using feature branches and publish straight to master
, so you won’t be able to track a change across packages. Then if, in the future, you need to revert the change, good luck finding all the pieces of code, across all packages, that were modified.
What can we do about it?
This is where the monorepo comes to save the day. Instead of having our code distributed across a multitude of repositories, we can have all packages hosted in a single repository.
The monorepo allows us to version-control all our packages together, so that creating a new branch and submitting a pull request will be done in a single place, including the code for all packages that may be affected by it.
However, we’re still bound by the constraints of Packagist: for distribution purposes, every package needs to live under its own repository.
What do we do now?
Hire our Laravel, CodeIgniter, YII, Zend, Cake PHP, Core PHP developers for your custom web development projects. Choose best PHP Web Frameworks & get satisfactory results.
Looking to develop a PHP based website from scratch or revamp your existing website? **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")** has always been an industry leader for companies and business owners looking to hire...
Are you looking for a php web development company? ValueCoders is a leading software company with 16+ years of experience offering PHP website development services to global clients. 4200+ projects | 2500+ Clients| 450+ Experts.
Our dedicated PHP developers write bug-free and optimized code for custom PHP web development projects. Hire us today and get satisfactory results.
Looking to hire affordable yet experienced PHP developers? **[Hire Dedicated PHP Developer](https://hourlydeveloper.io/hire-dedicated-php-developer/ "Hire Dedicated PHP Developer")**, who can convert your idea to reality, within the stipulated...