Loading...
Loading...
DDEV local development environment patterns for Drupal, including configuration, commands, database management, debugging tools, and performance optimization.
npx skill4agent add grasmash/drupal-claude-skills drupal-ddev/references/# Start project
ddev start
# Stop project
ddev stop
# Restart services
ddev restart
# SSH into web container
ddev ssh
# Run Drush commands
ddev drush cr
ddev drush status
ddev drush config:status
# Run Composer
ddev composer require drupal/module_name
ddev composer update
# Database operations
ddev import-db --file=backup.sql.gz
ddev export-db --file=backup.sql.gz
ddev snapshot
# View logs
ddev logs
ddev logs -f # Follow mode
# Describe project
ddev describe
# Access URLs
ddev launch # Open site in browsername: myproject
type: drupal10
docroot: web
php_version: "8.3"
webserver_type: nginx-fpm
database:
type: mariadb
version: "10.6"
nodejs_version: "20"
# Additional services
additional_services:
- solr
# Custom upload/execution limits
upload_dirs:
- web/sites/default/files
# Performance settings
performance_mode: mutagen # For macOS# Create project directory
mkdir myproject && cd myproject
# Initialize DDEV
ddev config --project-type=drupal10 --docroot=web --php-version=8.3
# Install Drupal via Composer
ddev composer create drupal/recommended-project
# Install Drush
ddev composer require drush/drush
# Start DDEV
ddev start
# Install Drupal
ddev drush site:install standard --site-name="My Site" --account-name=admin
# Launch site
ddev launch# Clone repository
git clone repo-url myproject && cd myproject
# Start DDEV (reads .ddev/config.yaml)
ddev start
# Install dependencies
ddev composer install
# Import database
ddev import-db --file=path/to/backup.sql.gz
# Import files (if needed)
ddev import-files --source=/path/to/files
# Run updates
ddev drush updb -y
ddev drush cr
# Launch
ddev launch# Option 1: Download backup and import
# Use your hosting provider's CLI or dashboard to create/download a DB backup
# Example with a generic provider:
scp user@remote.server:/path/to/backup.sql.gz backup.sql.gz
# Import to local
ddev import-db --file=backup.sql.gz
# Option 2: Using DDEV pull (if configured with a provider integration)
ddev pull --environment=live
# Run updates after import
ddev drush updb -y
ddev drush cr
# Sanitize for local (optional)
ddev drush sql-sanitize -y# Morning: Start project
ddev start
# Pull latest code
git pull origin main
# Update dependencies if needed
ddev composer install
# Clear cache
ddev drush cr
# Work on features...
# Create database snapshot before testing
ddev snapshot --name=before-testing
# Test changes...
# If needed, restore snapshot
ddev snapshot restore --name=before-testing
# Evening: Stop project
ddev stop# Enable Xdebug
ddev xdebug on
# Run your debugger in IDE (PHPStorm, VSCode)
# Set breakpoints and refresh page
# Disable when done (improves performance)
ddev xdebug off
# Check Xdebug status
ddev xdebug status{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
}
}# .ddev/config.yaml
performance_mode: mutagen# Restart after config change
ddev restart# .ddev/config.yaml
nfs_mount_enabled: true# .ddev/config.yaml
database:
type: mariadb
version: "10.6"
# Create .ddev/mysql/my.cnf
[mysqld]
innodb_buffer_pool_size = 512M
innodb_log_file_size = 128M.ddev/commands/web/.ddev/commands/web/fresh-install#!/bin/bash
## Description: Fresh Drupal install from scratch
## Usage: fresh-install
## Example: ddev fresh-install
set -e
echo "Installing fresh Drupal site..."
# Drop existing database
drush sql-drop -y
# Install Drupal
drush site:install standard \
--site-name="My Site" \
--account-name=admin \
--account-pass=admin \
-y
# Import config if exists
if [ -d /var/www/html/config/default ]; then
drush config:import -y
fi
# Clear cache
drush cr
echo "Fresh install complete!"
echo "Login: admin / admin"chmod +x .ddev/commands/web/fresh-install
ddev fresh-install# Restart project
ddev restart
# Check status
ddev describe
# View logs
ddev logs
# Clear Drupal cache
ddev drush cr# Check database is running
ddev describe
# Verify settings.php or settings.ddev.php exists
ddev ssh
ls web/sites/default/settings*.php# Stop all DDEV projects
ddev poweroff
# Check for port conflicts
lsof -i :80 -i :443
# Change router HTTP port if needed
ddev config --router-http-port=8080 --router-https-port=8443# Enable mutagen
ddev config --performance-mode=mutagen
ddev restart
# Or use NFS
ddev config --nfs-mount-enabled=true
ddev restart.ddev/php/drush.ini; Suppress PHP deprecation warnings for Drush commands
[PHP]
error_reporting = 22527
display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = /tmp/php-errors.logddev restarterror_reporting = 22527E_ALL & ~E_DEPRECATEDdisplay_errors = Offdisplay_startup_errors = Off/tmp/php-errors.log.ddev/php/*.ini/etc/php/[version]/cli/conf.d//etc/php/[version]/fpm/conf.d/Error response from daemon: error creating temporary lease: write /var/lib/desktop-containerd/daemon/io.containerd.metadata.v1.bolt/meta.db: input/output errorError response from daemon: open /var/lib/docker/overlay2/...: input/output errorkillall -9 Dockerkillall -9 com.docker.hyperkitddev startphpstatus:FAILEDmailpit:FAILEDddev mutagen reset# 1. Full power off to clean up all containers and networks
ddev poweroff
# 2. Start fresh
ddev startddev poweroff# 1. Stop DDEV
ddev stop
# 2. Reset the Mutagen daemon
~/.ddev/bin/mutagen daemon stop
~/.ddev/bin/mutagen daemon start
# 3. Reset Mutagen sync (removes Docker volume, forces full resync)
ddev mutagen reset
# 4. Start fresh
ddev startddev mutagen status -l # Detailed sync status
ddev mutagen monitor # Real-time sync progress
docker inspect --format "{{ json .State.Health }}" ddev-<project>-web # Container health# List all projects
ddev list
# Stop all projects
ddev poweroff
# Remove stopped projects
ddev delete <project-name>
# Remove all project containers (keep files)
ddev delete --omit-snapshot --yes <project-name>