Using Lando for Local Drupal Development with Pantheon Integration

Lando is a powerful local development tool based on Docker that simplifies the process of setting up complex environments. This post will guide you through using Lando to set up a local Drupal development environment that integrates seamlessly with Pantheon, a popular managed hosting platform for Drupal and WordPress sites.

Step 1: Installing Lando

First, you need to install Lando. It is available for Windows, macOS, and Linux. Download and install Lando from its official website. Ensure Docker is installed on your machine as Lando relies on it to run the development environments.

Step 2: Initializing a New Drupal Project

Once Lando is installed, you can start setting up your Drupal project. If you're starting a new project, you can initialize it directly with Lando. Open a terminal and run the following command:

Bash
lando init --source pantheon

You will be prompted to enter your Pantheon account details and select the specific Drupal site you want to work with if you have multiple projects.

Step 3: Configuring Your Lando Setup

After initializing your project, Lando will create a.lando.ymlfile in your project directory. This file contains all the configuration needed to run your Drupal site. You can customize this file to match your development needs, including PHP version, database configuration, and more.

YAML

name: my-drupal-site
recipe: drupal8
config:
  webroot: web
  php: '7.3'
  via: nginx
  database: mariadb:10.3
tooling:
  drush:
    service: appserver

This configuration sets up a Drupal 8 site running PHP 7.3 with Nginx and MariaDB.

Step 4: Starting Up Lando

With your.lando.ymlconfigured, you can start your Drupal environment by running:

Bash
lando start

Lando will start all the services defined in your.lando.ymlfile, and you will be given URLs to access your site locally.

Step 5: Syncing with Pantheon

To sync your local environment with Pantheon, use Lando’s integrated tooling. You can pull and push your databases, files, and code between your local setup and the Pantheon server:

Bash
 lando pull --code --database --files

This command will pull the latest code, database, and files from Pantheon to your local machine.

Using Lando for local Drupal development provides a powerful, flexible, and consistent development environment that mirrors your live hosting environment on Pantheon. This setup not only speeds up development and testing but also reduces inconsistencies between local and production environments.

Author: Richard Ford April 13, 2024, 8:38 PM