There are many development environment options available these days like DDev and DockSal, but we generally recommend Lando for a Drupal setup for a few reasons.

Lando is easy to work with, portable, and fast. And Lando can run anything, anywhere! It is the most approachable Devops tool and has been gaining popularity for years. A simple way to describe Lando is that it’s automated environment setup allows for easier development.

Lando Setup with Drupal

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 free and open source local development environment DevOps tool, built on Docker. It’s compatible with local environments on OSX, Windows, and Linux. Using Lando, you can prepare various types of services and tools effortlessly. Plus, 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: What’s the point of 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

Lando Services

 

Mailgog

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

App Server

 

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.

Events

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

 

Tooling - lando xdebug-on

This command will set and enable the xdebug-on on the app server for debugging.

Xdebug

 

Sources: https://docs.lando.dev/core/v3/

Final Thoughts

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. Or, you can hire an expert Drupal development agency to look into the entire process of Lando setup and development of your Drupal website.

Contact us

LET'S DISCUSS YOUR IDEAS. 
WE'D LOVE TO HEAR FROM YOU.

CONTACT US