How and what to distribute between your Lando based projects
Lando goodies — Part 2.
To work efficiently and at ease in the ever changing environment of web development, it is imperative to have projects share policies, structural standards and tools to cover default processes.
Shared project elements a.k.a. Greatest Common Divisor (GCD)
When you look at high variety of projects, you can easily recognise similarities, shared properties across projects. All together these are the projects Greatest common divisor (GCD).
Greatest Common Divisor (GCD)
In mathematics, the greatest common divisor (GCD) of two or more integers, which are not all zero, is the largest positive integer that divides each of the integers. This rather fundamental concept to number theory can be used to find the greatest common properties of project structures.
By identifying the GCD of the projects we can prepare a shared basic solution. Now let us collect some of these for any given Drupal 9 project:
- project is version controlled
- it has a database
- composer is handling the packages
In addition to these, we can add properties according to our own taste as in:
- Webroot is in the “web” folder
- Projects are using Redis
- Mailhog is used to catch php mails locally
- Project is covered with default ops scripts
Great! Now we have a list of some basic properties that should be applicable across every Drupal project where this base is being used. We just have to find a way to apply this to our Lando based project.
Luckily Lando provides an easy way for this via lando base files and we can distribute the solution with as a Git as a submodule.
Turning a single project into a Distribution
The .lando.base.yml of our “Base” project will contain the following elements
- configuration of the webroot
- base services (Mailhog, Redis)
- default ops scripts and it’s dependencies (for example appserver service has to be altered in order to make Xdebug work).
I’ve prepared an example here: https://github.com/cleverhoods/lando-goodies. Make sure you follow the the installation steps in the README!
The “Base” can be found here: https://github.com/cleverhoods/lando-base
Benefits of distributing
Distributing the local environment in this manner comes with immense benefits.
- You can develop a solution once and use it everywhere
- Onboarding becomes very easy thanks to the structural similarities
- It paves the path for further standardisation
- General policies can be used across all the projects which further reduce the time fragmentation and overhead.