Using Lando for WordPress Development Environments

Contents

Introduction

Modern WordPress development demands a reproducible, fast and isolated environment. Lando — a free, open-source local development tool built on Docker — fills this gap. It allows teams and solo developers to spin up WordPress (and other) stacks with zero manual Docker commands, consistent configuration, and powerful integrations.

What Is Lando

Lando is a local development environment abstraction layer that simplifies Docker usage. While you could write custom docker-compose.yml files, Lando provides:

  • Presets for popular frameworks (WordPress, Drupal, Laravel, etc.)
  • Tooling commands (wp-cli, composer, drush, npm)
  • Unified workflow across macOS, Linux and Windows
  • Network isolation to avoid port collisions
  • Service customization via .lando.yml

Official documentation: https://docs.lando.dev
WordPress project site: https://wordpress.org

Why Use Lando for WordPress

  • Consistency: Team members share identical .lando.yml allowing “it works on my machine” to become a relic of the past.
  • Speed: Containers launch in seconds vs. minutes for full VMs.
  • Flexibility: Swap PHP versions, databases (MySQL, MariaDB, Postgres), caching layers (Redis, Memcached) with minimal edits.
  • Extensibility: Connect third-party tools (Mailhog, Selenium, Solr).

Prerequisites

  • Docker (https://www.docker.com) installed and running
  • Git CLI
  • Basic familiarity with command line (bash, Zsh, PowerShell)

Installation

  1. Download the latest Lando release from Lando Installation.
  2. Run the installer and verify by executing:
    lando version
  3. Ensure Docker is up and your user has permission to use Docker.

Creating a WordPress Project with Lando

  1. Initialize in an empty directory:

    mkdir my-wp cd my-wp
    lando init --source remote --remote-url https://github.com/WordPress/WordPress.git --recipe wordpress --webroot . --name my-wp
  2. Start the environment:
    lando start
  3. Note the displayed URLs for your site and tooling services (e.g., mailhog, mysql).

Key Commands

Command Description
lando start Launches containers.
lando stop Stops but retains data.
lando destroy Removes containers and data volumes.
lando ssh Opens a shell in the app container.
lando wp Runs WP-CLI commands.

Customizing .lando.yml

The .lando.yml file controls services, tooling, and proxies. Here’s a slimmed example:

name: my-wp
recipe: wordpress
config:
nbspnbspwebroot: .
nbspnbspphp: 7.4
services:
nbspnbspdatabase:
nbspnbspnbspnbsptype: mariadb
nbspnbspnbspnbspversion: 10.4
tooling:
nbspnbspcomposer:
nbspnbspnbspnbspservice: appserver
nbspnbspdrush:
nbspnbspnbspnbspservice: appserver
proxy:
nbspnbspapp:
nbspnbspnbspnbsphttps: true

Notes:

  • You can switch php to any supported version (5.6–8.1 ).
  • Define multiple services (redis, mailhog) under services.
  • Use environment: to set environment variables (WP_ENV, etc.).

Data Management

Database Import/Export

  • Export:
    lando db-export backup.sql.gz
  • Import:
    lando db-import backup.sql.gz

Media Sync

Use rsync over SSH between host and container:

rsync -avh uploads/ lando@appserver:/app/wp-content/uploads/

Advanced Topics

Custom Services

Add Solr for search or Selenium for testing:

services:
nbspnbspsolr:
nbspnbspnbspnbsptype: solr
nbspnbspnbspnbspportforward: 8983
nbspnbspselenium:
nbspnbspnbspnbsptype: selenium

Then configure your tests or plugin to point to http://solr:8983.

Performance Tuning

  • Increase appserver memory/CPU in .lando.local.yml.
  • Enable OPcache via php.ini overrides.
  • Use cached volumes for node_modules or vendor directories.

Troubleshooting

  • Docker Desktop issues: Ensure virtualization is enabled (BIOS/Windows Features).
  • Port conflicts: Change proxy ports under proxy: in .lando.yml.
  • Memory limits: Adjust Docker resource allocation via settings.
  • Service logs: lando logs -s appserver or -s database.

Best Practices

  1. Version Control your .lando.yml and .lando.local.yml, but ignore volumes and state files.
  2. Use Local Overrides (.lando.local.yml) for machine-specific settings.
  3. Eliminate Global Installs: Rely on lando composer, lando wp, etc.
  4. CI Integration: Use Lando’s CI guide to replicate environments in CI pipelines.
  5. Secure Data: Don’t commit backups or dump files store them in secure vaults.

Conclusion

Adopting Lando for WordPress development accelerates onboarding, enforces parity, and enhances workflow efficiency. Its flexible configuration and powerful tooling make it an essential part of any modern WordPress developer’s arsenal.



Acepto donaciones de BAT's mediante el navegador Brave 🙂



Leave a Reply

Your email address will not be published. Required fields are marked *