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.
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.
Sweet! 💧