Drupal 8 and Lando

Overview

Below are steps to setup a local Drupal 8 composer based environment using Lando.

Prerequisites

You need to have Lando installed using these instructions.

Steps

Create a local folder. <app> will be the name of your application folder and Lando instance.

mkdir <app>

Position your working directory as your new folder

cd <app>

Initialize Lando and answer a few questions. This utility creates a .lando.yml file in your working directory. When you start Lando in the next step, this file is used to define the Lando configuration.

lando init
Choose: current working directory
Choose: Drupal8
Enter for webroot: web
Enter for app: <app>

Start Lando

lando start

Install Drupal code using composer. Note – Drupal is being install in a Docker container, not on your local computer.

Drupal 8.8 and Later:

lando composer create-project drupal/recommended-project blah -n

Prior to Drupal 8.8:

lando composer create-project drupal-composer/drupal-project:8.x-dev blah -n

The above command uses composer to install Drupal and it’s dependencies into a folder called ‘blah’. Now, the files/folders in ‘blah’ will be move up one level into your directory and the ‘blah’ folder will be removed.

mv blah/* .
mv blah/.* .
rm -rf blah

Rebuild Lando containers.

lando rebuild -y

On a success rebuilt on Lando, it’s time to install Drupal 8. Goto the local URL for your Drupal 8 website.

https://<app>.lndo.site  

Follow the steps in the Drupal installation Wizard. When the database page appears, use ‘drupal8’ for the database name, username and password. Also, use ‘database’ for the host name (under the Advanced settings.

You should be up and running,

Updates

12/10/2019 – As of Drupal 8.8.0, Composer project templates are now available as part of Drupal core. The composer create-project command was updated to reflect this change.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s