Web Wash: Getting Started with DDEV for Drupal Development

ddev addon get ddev/ddev-adminer
ddev restart

Install an add-on:

Generate a login link:

ddev drush uli

Essential DDEV Commands

Project Management

Visit addons.ddev.com to explore available add-ons including:

Don’t forget to subscribe to our YouTube channel to stay up-to-date.

DDEV homepage

Benefits of Using DDEV

ddev ssh -s db

Viewing Logs

ddev start
ddev composer create-project "drupal/recommended-project:^11"
ddev composer require drush/drush
ddev drush si standard -y

DDEV simplifies Drupal local development by providing a consistent, containerized environment that requires minimal configuration. Key features include:

To manually add debugging to VS Code without the DDEV manager, follow the documentation on the Visual Studio Code (VS Code) Debugging Setup page.

Quick Start Resources

hooks:
post-import-db:
- exec: drush sql:sanitize
- exec: drush updatedb
- exec: drush cache:rebuild
post-start:
- composer: install
- exec: drush user:login

Available Hook Events

Setting up a local Drupal development environment requires tools that handle web servers, databases, and PHP configuration. DDEV provides a Docker-based solution that simplifies this process while maintaining flexibility for different project requirements.

Get lifetime access to all premium courses, a private site builder forum, and exclusive live streams.

ddev logs
ddev logs -f # Follow logs in real-time
ddev logs -s db # Database container logs
ddev exec tail -f /var/log/nginx/access.log

Database Management

Importing Databases

The ddev config command creates a .ddev folder containing:

  • config.yaml: Main configuration file controlling project name, PHP version, web server type, and database settings.
  • .gitignore: Ensures only relevant configuration gets committed.
  • settings.ddev.php: Auto-generated Drupal settings file (do not modify this file).

The port changes each time containers start, so check ddev describe for the current value.

  • PHP version: Change to match your production environment.
  • Web server: Choose between nginx-fpm or Apache.
  • Database type: Switch between MariaDB, MySQL, or PostgreSQL.

Installing Drupal

Create a new project directory and configure DDEV:

DDEV provides several advantages for Drupal development:

The DDEV documentation provides quick start guides for various platforms including Drupal, Drupal CMS, and older Drupal versions. These guides contain copy-paste commands for rapid project setup.

Connect external tools like Sequel Ace or TablePlus:

  • ddev start: Start the project containers.
  • ddev stop: Stop containers without losing data.
  • ddev restart: Stop and start containers.
  • ddev list: View all DDEV projects on your system.
  • ddev describe: Display detailed project information including URLs and ports.
  • ddev poweroff: Stop all DDEV projects and services.

Running Commands in Containers

ddev snapshot --list

ddev export-db > db-export.sql.gz

additional_hostnames:
- drop-crm

In the video above, you’ll learn how to install and configure DDEV, create a new Drupal project, use essential commands for daily development, import and export databases, set up debugging with Xdebug, and extend DDEV with add-ons and custom commands.

ddev import-files --source=custom-files.zip

ddev snapshot restore

ddev ssh

With the DDEV Manager extension installed, debugging configuration happens automatically. Without the extension, add the configuration manually through Run > Add Configuration > PHP.

Install the DDEV Integration plugin from the JetBrains marketplace. Features include:

Export the current database:

Start with the basic setup and add features as your project requires them. The DDEV documentation provides detailed guidance for advanced configurations and troubleshooting.

Install DDEV using Homebrew:

Importing Files

Drupal 11 projects include Mailpit by default. This service captures all outgoing emails, preventing test emails from reaching real addresses. Access Mailpit through the URL shown in ddev describe.

DDEV uses Mutagen to sync files between the host and the container. This provides near-native file performance, even on macOS where Docker volume mounting can historically be slow.

IDE Integration

VS Code Setup

ddev snapshot --name=before-update

#!/bin/bash

## Description: Fresh Drupal install
## Usage: fresh-install

drush si standard -y
drush cr
drush uli

DDEV is a Docker-based PHP development environment that wraps Docker functionality into simple commands. The tool minimizes changes to your Drupal codebase, storing configuration in a dedicated .ddev folder and config.yaml file that you can commit to your repository.

  • Terminal dropdown to SSH directly into containers.
  • Automatic database connection configuration.
  • Quick access to project URLs and services.
  • Xdebug configuration with zero setup.

DDEV Add-ons

Browsing Available Add-ons

ddev config --additional-hostnames drop-crm
ddev restart

Turn on Xdebug:

Table of Contents

Mailpit Email Capture

Import the files directory:

Debugging with Xdebug

Enabling Xdebug

brew install ddev/ddev/ddev

If you encounter synchronization issues where file changes on your host do not reflect in the container, you can force a resync:

ddev import-db --file=db-export-custom-site.sql.gz

The extension creates the necessary .vscode/launch.json and .vscode/tasks.json files for debugging.

ddev mutagen sync

Install the DDEV Manager extension from the VS Code marketplace. This extension provides:

ddev xdebug on

ddev composer require drupal/admin_toolbar
ddev drush cr
ddev drush sqlc

mkdir drupal-crm
cd drupal-crm
ddev config --project-type=drupal11 --docroot=web

Start DDEV and install Drupal:

  • post-start: Run after ddev start completes.
  • post-import-db: Run after database import.
  • pre-stop: Run before stopping containers.
  • post-snapshot: Run after creating a snapshot.

Execute commands inside the web container:

Additional Hostnames

NOTE: Please refer to the documentation for the latest commands.

The config.yaml file allows customization of:

ddev xdebug off

PHPStorm Configuration

If you need to access your site via a different domain (e.g., mysite.ddev.site and api.mysite.ddev.site), use the additional_hostnames configuration.

Performance with Mutagen

Create reusable commands by adding shell scripts to .ddev/commands/web/:

Or you can manually edit the additional hostnames option in the config.yaml.

ddev export-db --gzip=false > db-export.sql

Database Snapshots

Before installing DDEV, you need Docker installed on your system. Options include:

  1. Run ddev describe to find the database port.
  2. Use localhost as the host.
  3. Enter db for username, password, and database name.
  4. Enter the port number from ddev describe.

Add hooks to config.yaml to automate tasks:

Summary

Hooks reduce manual steps and ensure consistent workflows across the team.

  • Simple project setup with the ddev config command and project type presets.
  • Built-in services like Mailpit for email testing and support for database management tools.
  • Extensibility through add-ons for services like Solr, Redis, and Elasticsearch.
  • Automation with custom commands and hooks for repetitive tasks.
  • IDE integration with extensions for VS Code and PHPStorm that simplify debugging.

ddev fresh-install

Command Locations

Place commands in different directories based on where they run:

Similar Posts