Lando 101

Using Lando in City of Boston.

In the context of this document: Think of Lando as a CLI for a Drupal LAMP stack constructed in docker.

What is Lando ?

For our purposes, Lando is a PHP-based tool-set which does 3 main things:

  1. Provides a pre-packaged local docker-based development environment,

  2. Provides a wrapper for common docker container management processes,

  3. Provides a means to execute development commands inside the container from the host.

Lando 101.

1. A Pre-packaged Drupal infrastructure on your local computer.

Lando curates an appropriate LAMP stack for Drupal development, largely removing the need for this skill in the local development team. The stack is contained within:

  • Docker images that are maintained by Lando.

  • A configuration file (landofile) which Lando parses into the necessary dockerfiles and utility scripts

COB uses a landofile which can be found at /[reporoot]/.lando.yml

2. Container Management

Lando provides a CLI for tasks developers commonly need to perform on the container.

A full list of defined Lando commands can be obtained by executing: lando

Command

Explanation

Starts all 3 lando containers, building them if they don't already exist.

Stops all 3 containers, but does not delete or destroy them. They can simply be restarted later.

Will rebuild the container using the values in the .lando.yml and .config.yml files.

  • If the containers have persistent images, these will be reused.

  • Any content in the database will be lost,

  • Project files cloned/managed by git will be left intact.

Will destroy the container.

  • If the containers have persistent images, these will be retained.

  • Any content in the database will be lost,

  • Project files cloned/managed by git will be left intact.

3. Command Line Interface for tasks in the

Lando provides a CLI for tasks developers commonly need to perform in the container.

Command

Explanation

Opens a bash terminal on the appserver docker container.

If the -c switch is used,

lando ssh -c "<command>"

then a terminal will be opened, the command provided will be run in the container and then the session will be closed.

eg: lando ssh -c "ls -la /app/docroot/modules/custom"

lando drush

Executes a drush cli command in the appserver container:

lando drush <command> eg lando drush status Note: a drush alias can be passed like this:

lando drush @alias <command>

eg: lando drush @bostond8.prod en dblog

lando drupal

Executes a Drupal cli command in the appserver container:

lando drupal <command>

lando composer

Executes a Composer command on the appserver container:

eg: lando composer require drupal/paragraphs:^1.3

lando drupal-sync-db

Executes a cob script which copies the database from the stage environment to the local development environment, and sync's all the configurations etc.

lando drupal-sync-db

lando drupal-pull-repo

Executes a cob script which pulls the latest project repository from gitHub and then clones and merges the private -repository. Finally it runs sync tasks to update the DB with any new configurations.

lando drupal-pull-repo

To update the repo's without sync'ing the content, execute:

lando drupal-pull-repo --no-sync

lando validate

Locally runs the linting and PHPCode sniffing checks that are run by Travis.

lando switch-patterns

Allows you to switch between patterns CDN hosts.

lando switch-patterns 2 switches to the local CDN in the patterns container

lando switch-patterns 3 switches to the production CDN

lando switch-patterns 4 switches to the stage patterns CDN.

A full list of defined Lando commands can be obtained by executing: lando

Lando Workflows.

- Pull and sync latest version of the github for the checked-out branch.

lando drupal-pull-repo

- Update local DB with content from Acquia Stage site

lando drupal-sync-db

- Update both code and DB locally, but leave container intact

lando drupal-pull-repo --no-sync && lando drupal-sync-db

- Completely rebuild local development environment

lando rebuild or to be completely sure, run these commands from the lando destroy && rm -rf <repo-path> git clone -b develop git@github.com:CityOfBoston/boston.gov-d8.git <repo-path> lando start

Last updated