ddev_exec
Execute shell commands inside DDEV project services (web, db, redis, solr) for testing, dependency management, and database inspection.
Instructions
Execute a shell command in the container for a DDEV service. Default: web service; use service (e.g. db, redis, solr) to run in another. workdir maps to ddev --dir. Usage: ddev exec [flags] [command] [command-flags] Flags: -s/--service (default web), -d/--dir (execution directory) For full options: ddev help exec
COMMON USE CASES:
Drupal (Drush):
"drush status" - Site status
"drush cr" - Clear cache
"drush uli" - Generate login link
"drush cex" - Export config
"drush cim" - Import config
"drush pm:install module_name" - Install module
"drush updb -y" - Run database updates
WordPress (WP-CLI):
"wp cli version" - WP-CLI version
"wp plugin list" - List plugins
"wp plugin install akismet --activate" - Install & activate plugin
"wp theme list" - List themes
"wp user list" - List users
"wp core update" - Update WordPress
"wp cache flush" - Clear cache
"wp search-replace old.com new.com" - Search/replace URLs
Composer:
"composer install" - Install dependencies
"composer update" - Update packages
"composer require vendor/package" - Add package
"composer show" - List installed packages
Redis:
"redis-cli INFO" - Server info
"redis-cli PING" - Test connection
"redis-cli KEYS *" - List keys
"redis-cli FLUSHALL" - Clear all caches
Solr:
"curl http://solr:8983/solr/admin/cores?action=STATUS" - Check cores
"curl http://solr:8983/solr/corename/select?q=:" - Query Solr
MySQL/MariaDB:
"mysql -e 'SHOW DATABASES'" - List databases
"mysql -e 'SHOW TABLES' db" - List tables
"mysql -e 'SELECT VERSION()'" - Database version
Platform.sh CLI:
"platform environment:list" - List environments
"platform db:dump" - Export database
Node.js/npm:
"npm install" - Install packages
"npm run build" - Build assets
"npm run test" - Run tests
"node --version" - Node version
Testing Frameworks:
"playwright test" - Run Playwright tests
"cypress run" - Run Cypress tests
"phpunit" - Run PHP unit tests
Other:
"php -v" - PHP version
"ls -la" - List files
"cat config/sync/system.site.yml" - Read file
"env" - Show environment variables
Dangerous commands blocked unless ALLOW_DANGEROUS_COMMANDS=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Command to execute. Examples: "playwright test" (run Playwright tests), "npm run test:e2e" (run E2E tests), "npm run build" (build assets), "redis-cli ping" (test Redis), "curl http://solr:8983/solr/" (test Solr). For Drush commands, use ddev_drush. For Composer commands, use ddev_composer. Dangerous commands are blocked unless ALLOW_DANGEROUS_COMMANDS=true. | |
| service | No | Service to execute in: web (default), db, redis, solr, or any other service. AUTO-ROUTING: npm/php commands → web, mysql/mariadb commands → db, redis-cli commands → redis, solr commands → solr | |
| workdir | No | Working directory for the command (e.g., "/var/www/html", "/var/www/html/drupal") | |
| projectPath | Yes | Path to the DDEV project directory |