How to Use Lando as a Drupal Development Environment

How to Use Lando as a Drupal Development Environment
Category
esembrat3
Drupal Version

What is Lando? From the Lando documentation:

It's a free, open source, cross-platform, local development environment and DevOps tool built on Docker container technology and developed by Tandem. Designed to work with most major languages, frameworks and services, Lando provides an easy way for developers of all skill levels to specify simple or complex requirements for their projects, and then quickly get to work on them.

In simpler terms, it is a container system built on Docker that runs on Windows, MacOS, and Linux, letting you spin up development websites with a minimum technical hassles.  It is just one of many ways to easily set up a Drupal 10 development site for either building a complete new website, doing module development work, or testing third-party modules in a safe "sandbox" environment.

Enabling a Mail Server in Lando

Enabling a Mail Server in Lando
Category
esembrat3
Drupal Version

The Lando Drupal 7 recipe does not come with mail functionality out-of-the-box. However, DrupalEasy has written straight-forward documentation on how to enable server mail functionality.

This is helpful for enabling mail notifications for password resets, trigger/Rules configuration.

Process

  1. Add the following configuration to your .lando.yml recipe:
    proxy:
      mailhog:
        - mail.lemp.lndo.site
    services:
      mailhog:
        type: mailhog
        hogfrom:
          - appserver
  2. Edit mail.lemp.lndo.site to better match, mirror, or apply to your local Lando website.

  3. Run "lando rebuild". Caution should be used when using using the 'rebuild' command, as while most services retain their data during a rebuild, some may not

  4. Running "lando start" will now initialize a Mailhog server, which will siphon all Drupal-generated mail into that inbox.

Lando and Mercury Reader

Lando and Mercury Reader
Category
esembrat3
Drupal Version

Mercury Reader requires an extra php extension outside of what lando's drupal10 recipe typically provides.

Process

Adjust your lando.yml Landofile to include the following:

services:  
  appserver:
    build_as_root:
      - apt-get update -y
      - apt-get install libxslt1-dev -y
      - docker-php-ext-install xsl
      - docker-php-ext-enable xsl

Rebuild your lando environment to install the libraries:

lando rebuild -y

 

Set up lando on Windows 10 for an easy local development environment

Set up lando on Windows 10 for an easy local development environment
Category
afrank30
Drupal Version
  1. First install WSL version 2. You do not need VSCode or Hyper-V and may not even need to install a specific version of Ubuntu (20.04 at the time of writing), as it usually defaults to the latest version.
  2. Next, install Docker Desktop for Windows (on Windows, NOT within the Ubuntu VM).
  3. Then, install lando's .exe from github (on Windows, NOT within the Ubuntu VM).

Starting a Drupal 10 Website with Lando

Starting a Drupal 10 Website with Lando
Category
esembrat3
Drupal Version

The below scenario assumes you have Lando installed on your own machine for local development.

Kickstarting a Drupal 9 website

Install Drupal via composer:

composer create-project drupal-composer/drupal-project:10.x-dev SITENAME --no-interaction

Enter SITENAME and init lando.

cd SITENAME
lando init

During the lando init process:

  • Select the appropriate recipe (drupal9) for lando.
  • Provide the webroot directory (web).
  • Provide a shortcut name for the lando app (your choice and preference).

Once completed, now start up your virtual environment with:

lando start

Lando will kickstart the virtual filesystems in your specified root directory and initialize a locally-hosted database and web server (using Docker).

When you see BOOMSHAKALAKA!, Lando has configured all the environment configurations and is ready to party.

Using Drupal 10 with Lando

Using Drupal 10 with Lando
Category
esembrat3
Drupal Version

Drupal Console, Drush and Lando

Lando provides scaffolding for tools like Drupal Console and Drush.

To use these tools within Lando, just pre-empt your command with lando to make sure it's running within the Lando interface.

For example, to install a new module in Drupal 8 using Drupal Console, use:

lando drupal moi module_name

Or, to clear all caches using Drupal Console, use:

lando drupal cc all

Please see the Lando Drupal 8 documentation for a full list of tools.