Since there already are many development environment options available today like DDev and DockSal, why should you go for Lando for a Drupal setup?
Well, the reason is simple!
Lando is easy to work with, portable, and fast. And Lando can run anything, anywhere! It is the most approachable Devops tool that is quickly gaining popularity. A simple way to describe Lando is that it’s automated environment setup allows for easier development.
In this article, we’ll talk about Lando, its setup, architecture, and how you can use Lando recipes with Drupal, along with Lando configuration. So, let’s get started!
What is Lando?
Lando is a powerful local development environment and DevOps tool which is free and open source, built on Docker. It is compatible with local environments on OSX, Windows, and Linux. Using Lando, you can prepare various types of services and tools effortlessly. Lando allows you to set different services for every project without affecting other projects working on Lando.
As a developer, it becomes super easy to set up the configuration in the service and tooling codebase, as well as the application configuration that needs to be run. Once the setup is complete, developers can enter the repository to run Lando and begin working on the project in complete isolation without disturbing the consistency in their development environments.
How does Lando work and Why should you use it? (Lando Recipes & Drupal)
You’re already aware of what Lando is and its compatibility with Drupal. Now, as some of you may be familiar with Docker, you might be wondering how similar Lando and Docker are. The Lando setup configuration is similar to Docker compose and the isolated development environment is similar to that of Docker containers.
But such a similarity raises the question: why do you need Lando when you have Docker installed? Here’s why:
- Lando enables you with a more organized process of using Docker containers with the help of pre-defined recipes.
- When the docker container environment isn’t compatible with Lando recipes, you can easily define a container by defining a Lando service. You can do this without typing docker exec commands or setting up Dockerfiles.
- You can use your own custom docker compose files instead of Lando recipes while you benefit from the local development networking.
- Additionally, you can use SSL handling per container, set up proxy and custom URLs for your services, and use simple build and run steps.
If you need help learning about the system requirements and installation of Lando for Drupal 9, refer to our blog here.
Configuring Lando Recipes
Recipes are a combination of services, proxies, and tooling designed as start-state-of-sane defaults for a particular use case. Lando's recipes are the highest abstraction of Lando, containing common combinations of services, events, and tooling.
Services are simplified but highly configurable docker containers. They can run build steps such as installing a PHP extension or running yarn install. Tooling allows users to run arbitrary commands or combinations of commands or combination of services when invoked. They’re incredibly useful while being super simple to use.
Config allows you to set some more important things your recipe provides. With Lando, you can configure and make changes according to your requirements.
For a better understanding, let’s take a deeper look into Lando services and tooling.
Lando Services
Lando services are simplified and highly configurable Docker containers. They should be able to run build steps and can be overridden to low levels. Services get automatic networking and security features.
Some of the most useful services are:
- Elasticsearch/Solr
- Mailhog
- Node
- PhpMyadmin
- Redis
- Memcache
- Varnish
Services - Build Steps
If you need additional on-server dependencies like PHP extensions or node modules, it sounds like a build step.
There are four major build steps:
- “Build” : runs as "you" and before your service boots up
- “Build_as_root” : runs as root and before your service boots up
- “run” : runs as "you" and after your service boots up
- “run_as_root” : runs as root and after your service boots up
How can you execute the four major steps?
- Use build to install application dependencies that are needed before you start your application
- Use build_as_root to install low level server packages required by your application
- Use run to install application dependencies or run build steps that require your application be started first
- Use run_as_root for any other post-start root level one-time setup commands.
Events
Events allow the user to run an arbitrary command before or after certain parts of the Lando runtime. In simple words, you can automate commands or tasks you might often or always run, either before or after something happens. Lando and App runtime events can be hooked into pre- or post-events.
You can also hook into pre and post-events for all tooling commands.
Adding Tooling for Lando Apps
Tooling allows you to run arbitrary commands on arbitrary services. Every Lando Drupal recipe ships with useful dev utilities. These are the commands that display on the Lando help page, such as
- Lando php
- Lando mysql
- Lando db-import
- Lando db-export
Here, using tooling we can create our custom commands and can define what these commands will do internally and on which containers. These also help us to expose certain services directly to the developer and automate processes.
Tooling - lando drupal-check
Whenever we execute this command, it will go into the app server service and will run the command to see if the code is as per the Drupal standard. If not, it will display appropriate error messages.
Tooling - lando xdebug-on
This command will set and enable the xdebug-on on the app server for debugging.
Next Steps?
Once you’ve set up Lando for your Drupal website, you can create custom services, and recipes, and use specific docker images for your services. Lando allows you to integrate with different server configurations and CI/CD. Additionally, you can also learn to automate testing to move ahead with your Lando recipes in Drupal.
Lando and Drupal blend well. And if you are already familiar with Docker and docker compose, setting up Lando for your Drupal website and using its recipes, combining the events, services, and tooling would be super easy for you!
Found this article useful? Here’s a really tiny URL of this article for you to copy, embed, or share: //--> //--> //-->
bit.ly/3WyZNoB
Click to copy URL to your clipboard
Author: Shreyal Mandot
Meet Shreyal Mandot, our Acquia-certified Solution Architect and Drupal 8 Grand Master, who has a passion for new technologies and travelling. In fact, he's already planning his next trip to Paris! Besides working, Shreyal enjoys road trips, swimming, and basketball.
Drupal 9 Drupal Development Drupal PlanetLeave us a Comment
Recent Blogs
ImageHow To Accelerate Drupal Development with Lando
ImageEverything you wanted to know about Drupal 10 - Q&A with Experts
Image7 Drupal Security Strategies you need to implement right away! (Includes top Drupal 9 Security Modules)
Want to extract the maximum out of Drupal? TALK TO USFeatured Success Stories
Upgrading and consolidating multiple web properties to offer a coherent digital experience for Physicians Insurance
Upgrading the web presence of IEEE Information Theory Society, the most trusted voice for advanced technology
Great Southern Homes, one of the fastest growing home builders in the United States, sees greater results with Drupal 9
View all Case Studies