For years, setting up a local Magento 2 environment was a ritual of pain: XAMPP with manual vhost configuration, fighting PHP versions, unreproducible “works on my machine” problems. DDEV solves this elegantly – Docker underneath, simple YAML configuration on top.
What is DDEV?
DDEV is a Docker-based CLI tool that automates creating local development environments for popular platforms – including Magento 2. A few commands and you have a working environment with nginx, PHP-FPM, MySQL, Redis, and Elasticsearch at the right versions.
Requirements
- Docker Desktop (macOS / Windows) or Docker Engine (Linux)
- DDEV CLI
- Composer
# Install DDEV on macOS via Homebrew brew install ddev/ddev/ddev # On Ubuntu/Debian curl -fsSL https://raw.githubusercontent.com/ddev/ddev/master/scripts/install_ddev.sh | bash ddev version
Initialising a Magento 2 project
mkdir magento2-dev && cd magento2-dev
ddev config --project-type=magento2 \
--project-name=magento2-dev \
--php-version=7.2 \
--docroot=pub
ddev start
This creates .ddev/config.yaml:
name: magento2-dev type: magento2 docroot: pub php_version: "7.2" webserver_type: nginx-fpm mariadb_version: "10.2"
Installing Magento 2 via Composer
ddev composer create --repository=https://repo.magento.com/ \
magento/project-community-edition:2.3.0 .
ddev exec bin/magento setup:install \
--base-url=https://magento2-dev.ddev.site \
--db-host=db --db-name=db --db-user=db --db-password=db \
--admin-firstname=Admin --admin-lastname=User \
--admin-email=admin@example.com \
--admin-user=admin --admin-password=Admin123! \
--language=en_US --currency=USD --timezone=America/Chicago \
--use-rewrites=1 \
--search-engine=elasticsearch6 \
--elasticsearch-host=elasticsearch --elasticsearch-port=9200
Useful daily DDEV commands
| Command | What it does |
|---|---|
ddev start |
Start the containers |
ddev stop |
Stop the containers |
ddev ssh |
Enter the web container |
ddev exec <cmd> |
Run a command inside the container |
ddev logs |
Show nginx/PHP logs |
ddev xdebug on |
Enable Xdebug |
ddev describe |
Show URL, ports, database credentials |
What you gain vs XAMPP
With XAMPP you have one global PHP for all projects. With DDEV each project has its own container with its own PHP version, independent database, and separate nginx. Moving a project to another machine means copying the directory with .ddev/config.yaml and running ddev start.
Summary
DDEV is my default choice for local Magento 2 development. Works consistently on macOS, Linux, and Windows, integrates with PHPStorm, handles Xdebug with a single command, and does not require Docker knowledge to get started.
