Drupal Ddev

Introduction

Drupal developer resume

May 24, 2018 Run ddev in the terminal to test your installation. Configuring DDEV in our Project To demonstrate the configuring process, I will be taking a demo Drupal 8 project. Run the command ddev list, you can see that there are no running ddev projects. Use Git to clone the repository of the project in which you have to set up DDEV. DDEV advances open source communities such as Drupal by supplying tools, mentorship support, and collaboration to solve challenges without community bias. If we solve common challenges together, we can do a lot of good for a lot of people very quickly.

DDEV is an open source tool that uses docker to quickly create local PHP development environments. It has different templates for different frameworks/CMS such as generic PHP, WordPress, Drupal, TYPO3, Backdrop, Magento, Laravel, etc.

Drupal Ddev

One of the objectives of this type of tool is to ensure that local environments are homogeneous, which enhances workflows in development teams, as each member works with the same technological versions.

In this post we will see how to install and deploy in a few minutes a local DDEV environment in ubuntu using Drupal 9.

Prerequisites

A local machine with:

  • Linux: Ubuntu 16.04+, Debian Jessie + or Fedora 25+
  • Docker version 18.06 or higher and docker-compose 1.21.0 o higher installed.
  • Git version control (only for the installation of existing projects).

Installation and configurations

Installing DDEV on Linux:

Installation via Linuxbrew:

For the installation of ddev it is recommended to install it using the Homebrew package manager on Linux. Once this manager is installed, the commands to execute are as follows:

To install the latest stable version of DDEV:

To install the latest version:

If in the future you wish to upgrade the version of ddev on your computer, simply close ddev and upgrade.

Once DDEV is installed or updated, we verify the software with the following command:

And we will be able to check the installed or updated version.

Installation via command line:

Pre-installation packages:

Installing ddev:

Once DDEV is installed, we verify the software with the following command:

DDEV commands

With the command ddev or ddev -h we will obtain the list of commands provided by ddev. All of them must be executed in the root of the project. There are some of them:

  • ddev config: Configure a project for ddev. For example for a drupal distribution, wordpress, etc.
  • ddev ssh: Allows access inside the container.
  • ddev start: Starts the container.
  • ddev stop: Stops the container.
  • ddev import-db: Imports a database.
  • ddev export-db: Exports a database.
  • ddev composer: Allows to run composer inside the container. For example: ddev require drupal/module
  • ddev xdebug: Enables xdebug
  • ddev drush: Direct access to the drush CLI. For example: ddev drush cr
  • ddev logs: To display the apache log

Container for a Drupal 9 project

Installation of a new project:

Create the root directory:

We access the folder:

We create the project-specific directory structure:

Ddev

Within the folder we will have created a directory tree as shown below.

The settings.php will include the settings.ddev.php file created with the installation of ddev. This file will be the one with the necessary settings for our drupal references, for example the database connection or configuration directory.

We start the container.

The above command will show an output like the one below:

Drupal Devel Module

So now we have our container up and the web access urls available, which are shown in the image above. If we access these urls we get a 403 error, and this is because the drupal project is not yet installed. It is necessary to install it using the composer package manager as shown below.

We install drupal using composer, which will download the drupal core with all its dependencies.

Once executed, we will have a drupal project writing the urls previously mentioned in our browser. Another way to access the url is by executing the command 'ddev launch' which will open a browser window with the url generated by ddev.

Drupal Ddev Login

Installing drush for drupal:

At this point we can install drupal via the front-end (using the installation wizard) or via drush.

Installation of an existing drupal 9 project:

Clone the repository:

Access the folder:

We create the directory structure that ddev needs:

At this point you should check if the settings.ddev file is being included in the settings.php of the application and see if it is properly referenced.

Drupal Devel Php

We start the container:

Import the database:

And access to the browser:

Conclusions

  • DDEV provides us with a pre-configured local development environment for drupal with a quick setup in just a few minutes.
  • It allows to have several environments up at the same time.
  • No knowledge of docker is required.
  • We have tools such as Composer, Drush or XDebug available for our developments.