Bhooraj
by Bhooraj
6 min read

Categories

Tags

Developing a Drupal 8 site or blog with a hosting plan that supports Drupal 8 installation is relatively easy to do than doing it locally. This adds to the upfront cost, even though you just wanted to see how Drupal 8 works.

If you wish to develop a Drupal 8 blog or site locally, a few solutions can help you to do so.

‘Acquia Dev Desktop’ is one of them, it helps in creating a local development environment for Drupal 8. But, it only have the installer for Mac and Windows.

Installing ‘Ampps’, ‘WampServer’, or a ‘LAMP’/’LEMP’ stack could be one of the options as well.

But, I have found Lando makes it easier to do so. Irrespective of the operating system or distro you are working on. Moreover, it runs as an ‘abstraction layer’ to spin up docker containers with sane defaults.

Let us look at the steps on how to install and use Lando for creating a local development environment for Drupal 8.



1. Prerequisites for creating a development environment for Drupal 8 with Lando:

1. Install Docker

For Lando to work, we need to install Docker for Mac/Docker for Windows/Docker CE (if it’s not already installed).

2. Install Lando

3. Install Composer

Composer needs to be installed globally. This will ensure to pull Drupal 8 codebase using composer.

4. Install NodeJS and NPM

‘nodejs’ and ‘npm’ should be installed to install npm packages. Themes or some modules for Drupal 8 might need these packages.

2. Creating the Local development environment for Drupal 8 with Lando.

  1. Open the terminal from the home directory. This can be from anywhere as well. Note: You may use Git Bash if you are using windows.

  2. Use the following command to create a folder named ‘my_site_name_dir’ and pull the Drupal 8 code inside it.

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

    Note: Change ‘my_site_name_dir’ to ‘drupaldev’ for this example.

  3. Go inside the created directory.

  4. Add a .lando.yml file (inside the directory ‘drupaldev’) with Drupal 8 recipe mentioned here: https://docs.devwithlando.io/tutorials/drupal8.html

  5. Open the terminal from this directory. (Be sure about your path when in terminal. You should be inside the ‘drupaldev’ directory.) Enter the following command:

    $ lando start

  6. The above command will create services like apache, php and mysql necessary for Drupal 8 development environment. Note the details shown in the output, we will need this to access the Drupal site later.

    We can also use $ lando info to get this information.

  7. Use this command to install drush 8.x or downgrade the previous version installed. lando composer require drush/drush 8.x

  8. A development environment for Drupal 8 has been created.

Now we are ready to experiment and start developing with Drupal 8.

Note: Use the command $ lando stop to kill the app (environment) created. To completely erase the database and server environment use: $ lando destroy [app name]


Important links:


You may add your impressions regarding the blog post here: