Legacy Versions

The configuration for Drupal 8, Drupal 7 and Drupal 6 is mostly the same as Drupal 9+. This doc is intended to call out the notable deviations.

Drupal 8

Quickstart

# Initialize a drupal8 recipe using the latest Drupal 8 version
mkdir my-first-drupal8-app \
  && cd my-first-drupal8-app \
  && lando init \
  --source remote \
  --remote-url https://ftp.drupal.org/files/projects/drupal-8.9.20.tar.gz \
  --remote-options="--strip-components 1" \
  --recipe drupal8 \
  --webroot . \
  --name my-first-drupal8-app

# Start it up
lando start

# Install drupal
lando drush si --db-url=mysql://drupal8:drupal8@database/drupal8 -y

# List information about this app.
lando info

Default Configuration

recipe: drupal8
config:
  php: '7.3'
  composer_version: '2.2.12'
  via: apache:2.4
  webroot: .
  database: mysql:5.7
  drush: ^8
  xdebug: false

Using Drush

By default, our Drupal 8 recipe will globally install the latest version of Drush 8open in new window or the latest version of Drush 7open in new window if you are using php 5.3. This means that you should be able to use lando drush out of the box.

That said you can configure this recipe to use any version of Drush to which there is a resolvable package available via composer. That means that the following are all valid.

Use the latest version of Drush

recipe: drupal8
config:
  drush: "*"

Use the latest version of Drush 7

recipe: drupal8
config:
  drush: ^7

Use a specific version of Drush 8

recipe: drupal8
config:
  drush: 8.1.15

Using a site-local Drush

While Lando will globally install Drush for you, it is increasingly common and in some cases a straight-up best practice to install a site-local Drushopen in new window by requiring it in your projects composer.json file.

Because of how Lando's php serviceopen in new window sets up its PATHopen in new window, this means that if you have indeed installed Drush on your own via composer Lando will use yours over its own.

Said more explicitly: if you've required drush via composer in your application then this recipe will use your drush and not the one you've specified in this recipes config.

If you are using a site-local Drush, it is also recommended to configure a build step to automatically install Drush before your app starts up. This can prevent weird version mismatches and other issues if you are using Drush in other Lando automation like events.

Automatically composer install before my app starts

recipe: drupal8
services:
  appserver:
    build:
      - composer install

If you find that Lando is not using your drush as expected, which can happen if you've modified composer to install in a different directory than its normal vendor, you can take advantage of Lando's tooling overrides and specify an absolute path to your Drush.

tooling:
  drush:
    cmd: /path/to/my/drush

Default URL Setup

You may see http://default show up in many drush commands you run.

lando drush uli
// http://default/user/reset/1/1548025070/Px6PbLyJ_2laXqoDe6OukHXaX-cXExo4ErfrKbkqsE4/login

This happens because it is actually a difficult problem for Lando to 100% know the canonical URL or service that is serving your application. However you can set up your environment so that commands like lando drush uli return the proper URL.

Set a specific local drush uri value by adding a setting for DRUSH_OPTIONS_URI in the relevant service. You will need to run lando rebuild after adding this setting.

services:
  appserver:
    overrides:
      environment:
        DRUSH_OPTIONS_URI: "https://mysite.lndo.site"

Aliases

You can also use drush aliases with command like lando drush @sitealias cc all by following the instructions below.

Make sure the alias file exists within the drush folder in your app. An example could be the files structure below:

|-- app
   |-- drush
      |-- yoursite.aliases.drushrc.php

For info on how to setup your alias, please refer to the following linkopen in new window or see this exampleopen in new window.

Then configure the following build step in your Landofile and lando rebuild.

services:
  appserver:
    build:
      - mkdir -p ~/.drush/site-aliases
      - ln -sf /app/drush/yoursite.aliases.drushrc.php ~/.drush/site-aliases/yoursite.drushrc.php

Configuring your root directory

If you are using a webroot besides ., you will need to remember to cd into that directory and run lando drush from there. This is because many site-specific drush commands will only run correctly if you run drush from a directory that also contains a Drupal site.

If you are annoyed by having to cd into that directory every time you run a drush command, you can get around it by overriding the drush tooling command in your Landofile so that Drush always runs from your webroot.

Note that hard coding the root like this may have unforeseen and bad consequences for some drush commands such as drush scr.

tooling:
  drush:
    service: appserver
    cmd: drush --root=/app/PATH/TO/WEBROOT

Drupal 7

Quickstart

# Initialize a drupal7 recipe using the latest Drupal 8 version
mkdir my-first-drupal7-app \
  && cd my-first-drupal7-app \
  && lando init \
  --source remote \
  --remote-url https://ftp.drupal.org/files/projects/drupal-7.71.tar.gz \
  --remote-options="--strip-components 1" \
  --recipe drupal7 \
  --webroot . \
  --name my-first-drupal7-app

# Start it up
lando start

# Install drupal
lando drush si --db-url=mysql://drupal7:drupal7@database/drupal7 -y

# List information about this app.
lando info

Default Configuration

recipe: drupal7
config:
  php: '7.2'
  composer_version: '2.0.7'
  via: apache:2.4
  webroot: .
  database: mysql:5.7
  drush: ^8
  xdebug: false

Using Drush

By default, our Drupal 7 recipe will globally install the latest version of Drush 8open in new window or the latest version of Drush 7open in new window if you are using php 5.3. This means that you should be able to use lando drush out of the box.

That said you can configure this recipe to use any version of Drush to which there is a resolvable package available via composer. That means that the following are all valid.

Use the latest version of Drush

recipe: drupal7
config:
  drush: "*"

Use the latest version of Drush 7

recipe: drupal7
config:
  drush: ^7

Use a specific version of Drush 8

recipe: drupal7
config:
  drush: 8.1.15

Using a site-local Drush

While Lando will globally install Drush for you it is increasingly common and in some cases a straight-up best practice to install a site-local Drushopen in new window by requiring it in your projects composer.json file.

Because of how Lando's php service sets up its PATH this means that if you have indeed installed Drush on your own via composer Lando will use yours over its own.

Said more explicitly: if you've required drush via composer in your application then this recipe will use your drush and not the one you've specified in this recipes config.

If you are using a site-local Drush, it is also recommended to configure a build step to automatically install Drush before your app starts up. This can prevent weird version mismatches and other issues if you are using Drush in other Lando automation like events.

Automatically composer install before my app starts

recipe: drupal7
services:
  appserver:
    build:
      - composer install

If you find that Lando is not using your drush as expected, which can happen if you've modified composer to install in a different directory than its normal vendor you can take advantage of Lando's tooling overrides and specify an absolute path to your Drush.

tooling:
  drush:
    cmd: /path/to/my/drush

Default URL Setup

You may see http://default show up in many drush commands you run.

lando drush uli
// http://default/user/reset/1/1548025070/Px6PbLyJ_2laXqoDe6OukHXaX-cXExo4ErfrKbkqsE4/login

This happens because it is actually a difficult problem for Lando to 100% know the canonical URL or service that is serving your application. However, you can set up your environment so that commands like lando drush uli return the proper URL.

Create or edit the relevant settings.php file and add these lines. Note that you may need to specify a port depending on your Lando installation. You can run lando info to see if your URLs use explicit ports or not.

$base_url = "http://mysite.lndo.site:PORT_IF_NEEDED"

Aliases

You can also use drush aliases with a command like lando drush @sitealias cc all by following the instructions below.

Make sure the alias file exists within the drush folder in your app. An example could be the files structure below:

|-- app
   |-- drush
      |-- yoursite.aliases.drushrc.php

For info on how to set up your alias, please refer to the following linkopen in new window or see this exampleopen in new window.

Then configure the following build step in your Landofile and lando rebuild.

services:
  appserver:
    build:
      - mkdir -p ~/.drush/site-aliases
      - ln -sf /app/drush/yoursite.aliases.drushrc.php ~/.drush/site-aliases/yoursite.drushrc.php

Configuring your root directory

If you are using a webroot besides ., you will need to remember to cd into that directory and run lando drush from there. This is because many site-specific drush commands will only run correctly if you run drush from a directory that also contains a Drupal site.

If you are annoyed by having to cd into that directory every time you run a drush command, you can get around it by overriding the drush tooling command in your Landofile so that Drush always runs from your webroot.

Note that hard coding the root like this may have unforeseen and bad consequences for some drush commands such as drush scr.

tooling:
  drush:
    service: appserver
    cmd: drush --root=/app/PATH/TO/WEBROOT

Drupal 6

Quickstart

# Initialize a drupal8 recipe using the latest Drupal 8 version
mkdir my-first-drupal8-app \
  && cd my-first-drupal8-app \
  && lando init \
  --source remote \
  --remote-url https://ftp.drupal.org/files/projects/drupal-8.9.20.tar.gz \
  --remote-options="--strip-components 1" \
  --recipe drupal8 \
  --webroot . \
  --name my-first-drupal8-app

# Start it up
lando start

# Install drupal
lando drush si --db-url=mysql://drupal8:drupal8@database/drupal8 -y

# List information about this app.
lando info

Default Configuration

recipe: drupal6
config:
  php: '5.6'
  composer_version: '2.0.7'
  via: apache:2.4
  webroot: .
  database: mysql:5.7
  drush: ^8
  xdebug: false

Using Drush

By default, our Drupal 6 recipe will globally install the latest version of Drush 8open in new window or the latest version of Drush 7open in new window if you are using php 5.3. This means that you should be able to use lando drush out of the box.

That said you can configure this recipe to use any version of Drush to which there is a resolvable package available via composer. That means that the following are all valid.

Use the latest version of Drush

recipe: drupal6
config:
  drush: "*"

Use the latest version of Drush 7

recipe: drupal6
config:
  drush: ^7

Use a specific version of Drush 8

recipe: drupal6
config:
  drush: 8.1.15

Configuring your root directory

If you are using a webroot besides ., you will need to remember to cd into that directory and run lando drush from there. This is because many site-specific drush commands will only run correctly if you run drush from a directory that also contains a Drupal site.

If you are annoyed by having to cd into that directory every time you run a drush command, you can get around it by overriding the drush tooling command in your Landofile so that Drush always runs from your webroot.

Note that hard coding the root like this may have unforeseen and bad consequences for some drush commands such as drush scr.

tooling:
  drush:
    service: appserver
    cmd: drush --root=/app/PATH/TO/WEBROOT