top of page

Using Lando for Drupal Development

Lando is for developers who want to quickly specify and painlessly spin up the services and tools needed to develop their projects. It's a free, open source, cross-platform, local development environment and DevOps tool built on Docker container technology and developed by Tandem.

Mostly, I use Lando for local Drupal development. It's incredibly easy to get a Drupal site up and running with Lando, and setting up important extras is easy, too. To begin with, let's create a new Drupal 8 project. We'll be using the Drupal 8 composer project, so we get drush and Drupal Console right out of the gate.

First, download Lando. You can visit their GitHub page and click on Releases to download the most recent version, here. Install Lando and Docker, and then we'll set up our new Drupal site.

composer create-project drupal-composer/drupal-project:8.x-dev landod8 --stability dev --no-interaction


Once that's all done, change to the landod8 directory and set up Lando.

cd landod8
lando init

It'll ask you what recipe you want. We're going to chose Drupal 8.

Then we'll specify our web root as web, and we'll label our application. I'm calling this LandoD8. Lando will apply some dashes for you to match your camel casing and will convert it to lando-d-8.


We want some additional options in our container. We want to be able to debug our code, so we'll turn on xdebug.

Edit your .lando.yml file and add

xdebug: true

under webroot: web. We are also going to be good developers and include phpunit in our setup.

Add this at the bottom of your .lando.yml file:

    service: appserver
    cmd: vendor/bin/phpunit


Now we're ready to start it up. Type

lando start

and watch it go.


Then browse to your site and walk through site install.


For your database username, password, and database name, answer


and then click Advanced Options and replace "localhost" in the Host field with "database". Press "Save and continue" and let it finish installing.


Once you've finished the installation, you have a new, clean Drupal 8 site that you can debug, run tests against, and manage using Composer.

For running phpunit tests, copy the web/core/phpunit.xml.dist to web/core/phpunit.xml and use these settings:

   <env name="SIMPLETEST_BASE_URL" value="">
    <env name="SIMPLETEST_DB" value="sqlite://localhost/sites/default/files/.ht.sqlite">
    <env name="BROWSERTEST_OUTPUT_DIRECTORY" value="/app/web/sites/simpletest/browser_output">


Getting an existing site running on Lando is just as simple. Clone your code, then from the project directory, run through all of the steps above up through running the site install. Instead of installing a new site, we'll import a backup of our current database and set up our settings manually. Copy your database backup into your project directory (remember that Docker is container-based, so if it's outside of your project directory, the container won't be able to see it), then use

lando db-import backup.sql

to import the database.

Edit your settings (for this example, we're putting our database info at the end of our settings.php file instead of having a separate settings.local.php):

$databases['default']['default'] = array (
  'database' => 'drupal8',
  'username' => 'drupal8',
  'password' => 'drupal8',
  'prefix' => '',
  'host' => 'database',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',

Now you should be able to see your site. If you ever need to get the URL again, type

lando info

and it'll display a bunch of information about your instance.


At this point, we can browse to our site, hit our breakpoints with xdebug, and we can even run tests. Let's tell Lando to run some tests in the container. The big_pipe module has some and they run pretty fast. Here we go!

lando phpunit -c web/core web/core/modules/big_pipe/tests/src/Unit


You can set up additional services that are helpful for Drupal development. At the time of this writing, there is a problem downloading PhantomJS with curl or wget, so we'll cheat by visiting and downloading the Linux 64-bit binary into our project root. Remember that it needs to go into the project directory so that the container can access it. Then add some steps your .lando.yml file:

      - "apt-get update -y"
      - "apt-get install build-essential chrpath libssl-dev libxft-dev libfreetype6-dev libfreetype6 libfontconfig1-dev libfontconfig1 -y"
      - "tar xvjf /app/phantomjs-2.1.1-linux-x86_64.tar.bz2 -C /usr/local/share/"
      - "ln -s /usr/local/share/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin/"

And add some new tooling so Lando can run it:

    service: appserver
    description: "Run phantomjs commands"


Restart your server with

lando restart

and let it execute the new changes.


Now you can open a new terminal tab and run PhantomJS for Drupal testing:

lando phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768

Then come back to our original tab and let's test big_pipe again, but this time we'll run the functional tests. Your tests will run much, much faster with debugging turned off. Comment out your

xdebug: true

in your .lando.yml file with a # and then run

lando restart
lando phpunit -c web/core web/core/modules/big_pipe/tests/src/FunctionalJavascript

This will take a couple minutes. Web testing isn't fast. But when it's done, you'll see that we've passed!


Now you have a Docker container running your Drupal 8 site and you're on your way to productivity. Enjoy!

2,011 views0 comments

Recent Posts

See All


bottom of page