Drupal Training 1: Local Development Environment

DDEV is the most popular local development environment for Drupal. Here's an outline of how to use it, and a minimum of what should be covered in a training module about using DDEV with Drupal.

The Confident Logo, Drupal Agency led by Mark Conroy

DDEV is a powerful tool for local web development, particularly useful for PHP-based applications like Drupal, WordPress, and TYPO3. It simplifies environment setup and project management using Docker containers. Here is a basic guide for setting up and using DDEV.

Installation

  1. Ensure Docker/Orbstack or similar is installed and running on your system.
  2. Install DDEV by following the instructions on the official DDEV documentation.

Project Setup (General)

  1. Create a Project Directory: Make a new directory for the project or navigate to an existing one.
  2. Initialise DDEV: Run ddev config in the project directory. The command will prompt for the project type (e.g., drupal, wordpress) and document root.
  3. Start DDEV: Execute ddev start to start the environment. DDEV will automatically create the necessary Docker containers.
  4. Access the Project: Visit the local URL provided by DDEV. Typically, it will be in the format http://projectname.ddev.site.

Project Setup (LocalGov Drupal)

  1. Get the LGD Project via composer.
  2. Run ddev start to start the project.
  3. Run ddev composer install to get all the dependencies.
  4. Run ddev drush si localgov -y to install a new version of LGD or ddev import-db -f /path/to/database.sql if you already have a copy of the site's database.

Database Management

DDEV provides easy access to the project's database:

  1. Use ddev ssh to enter the container's shell.
  2. Run commands like mysql to interact with the database.

Common Commands

  • Start Services: ddev start
  • Restart Services: ddev restart
  • Stop Services: ddev stop
  • Import Database: ddev import-db --file=database.sql.gz
  • Export Database: ddev export-db --file=database.sql.gz
  • Drush: ddev drush <drush command> e.g. ddev drush cr
  • Composer: ddev composer <composer command> e.g. ddev composer install
  • Destroy Project: ddev delete (removes containers but keeps the codebase)

Troubleshooting

If encountering issues, check logs using ddev logs or rebuild the project using ddev stop --unlist && ddev start.

Further Learning

For more advanced configurations, refer to the DDEV documentation for in-depth tutorials and customised settings. This resource provides detailed guides on using additional features like HTTPS support, additional services, and more.

Course: Build a LocalGov Drupal Website

Subscribe to get updates about the course (and perhaps a discount code before it is launched).

Filed Under:

  1. LocalGov Drupal
  2. Drupal
  3. DDEV
  4. Drupal Training