Pairing Composer template for Drupal Projects with Lando gives you a fully working Drupal environment with barely any setup.
Lando is an open-source, cross-platform local development environment. It uses Docker to build containers for well-known frameworks and services written in simple recipes. If you haven’t started using Lando for your local development, we highly recommend it. It is easier, faster, and relatively pain-free compared to MAMP, WAMP, VirtualBox VMs, Vagrant or building your own Docker infrastructure.
You’ll need to have Composer and Lando installed:
Setting up Composer Template Drupal Project
If you want to find details about what you are getting when you install the drupal-project you can view the repo. Otherwise, if you’d rather simply set up a Drupal template site, run the following command.
composer create-project drupal-composer/drupal-project:8.x-dev [your-project] --stability dev --no-interaction
Once that is done running,
cd into the newly created directory. You’ll find that you now have a more than basic Drupal installation.
Getting the site setup on Lando
lando init, which prompts you with 3 simple questions:
? What recipe do you want to use? > drupal8 ? Where is your webroot relative to the init destination? > web ? What do you want to call this app? > [your-project]
Once that is done provisioning, run
lando start—which downloads and spins up the necessary containers. Providing you with a set of URLs that you can use to visit your site:
https://localhost:32807 http://localhost:32808 http://[your-project].lndo.site:8000 https://[your-project].lndo.site
Visit any of the URLs to initialize the Drupal installation flow. Run lando info to get the database detail:
Database: drupal8 Username: drupal8 Password: drupal8 Host: database
Working with your new Site
One of the useful benefits of using Lando is that your toolchain does not need to be installed on your local machine, it can be installed in the Docker container that Lando uses. Meaning you can use commands provided by Lando without having to install other packages. The commands that come with Lando include
lando drupal, and
lando composer. Execute these commands in your command prompt as usual, though they’ll execute from within the container.
Once you commit your lando.yml file others can use the same Lando configuration on their machines. Having this shared configuration makes it easy to share and set up local environments that have the same configuration.