Powerful digital products, engineered in Kerala for organisations everywhere.
+91 95399 51353 opsintech@icloud.com Privacy + data protection
← Back to the journal DDEV commands

DDEV command guide for PHP and Magento projects

A practical, copy-ready DDEV reference for project setup, lifecycle commands, logs, database backups, Composer, Magento, and safe cleanup.

Editorial image for DDEV command guide for PHP and Magento projects
DDEV commands / OpsinTech insight
01

Step 1: configure and start the project

Run these commands from the project directory. Choose the document root and PHP version supported by the application; placeholders are intentionally not real values.

Configure a PHP project

Creates or updates DDEV configuration for a conventional PHP application whose public entry point is in public/.

ddev config --project-type=php --docroot=public --php-version=<supported-php-version>
When to use itUse this once when onboarding an existing Laravel or custom PHP repository.

Configure a Magento project

Selects DDEV’s Magento project type and Magento’s pub/ web root.

ddev config --project-type=magento2 --docroot=pub --php-version=<supported-php-version>
When to use itUse this before starting a newly cloned Magento Open Source project.

Start the environment

Builds and starts the project containers, then reports the local project URLs.

ddev start
When to use itRun after cloning a configured project or after a machine restart.

Inspect the environment

Shows project URLs, services, ports, database details, and current status without changing the environment.

ddev describe
When to use itUse this first when a URL, port, or service name is unclear.
02

Step 2: control and diagnose the environment

These lifecycle commands cover the daily loop. Use poweroff when you want to stop every DDEV project, not just the current one.

Restart after configuration changes

Stops and starts the current project so configuration changes take effect.

ddev restart
When to use itRun after editing .ddev/config.yaml or adding a service.

Follow application logs

Streams logs from the web container until you stop the command.

ddev logs -f
When to use itKeep this open while reproducing a 500 error or failed request.

Open a container shell

Starts an interactive shell inside the web container with the project directory mounted.

ddev ssh
When to use itUse when several container-side commands must be run in sequence.

Run one container command

Executes one command in the web container without opening an interactive shell.

ddev exec <command>
When to use itFor example, replace the placeholder with php -v to verify the active container PHP version.

Stop one or all projects

The first command stops the current project. The second stops every running DDEV project and supporting container.

ddev stop
ddev poweroff
When to use itUse stop at the end of work on one project; use poweroff before shutting down Docker.
03

Step 3: back up, inspect, and restore the database

Treat imports and project deletion as destructive operations. Create an export or snapshot first and verify that you are in the intended project.

Create a portable database export

Writes the current project database to a compressed file that can be archived or imported elsewhere.

ddev export-db --file=backup.sql.gz
When to use itCreate a named backup before setup:upgrade, a large data import, or a risky local experiment.

Create a quick local snapshot

Stores a named database snapshot managed by DDEV for quick local recovery.

ddev snapshot --name=before-change
When to use itUse immediately before testing an upgrade or migration.

Import a database

Replaces the project database with the selected dump.

ddev import-db --file=backup.sql.gz
When to use itUse for a reviewed local backup; do not point it at an unverified or production-connected project.
CautionDestructive: the current project database is replaced. Export it first.

Open the database client

Connects to the project database using DDEV-managed local credentials.

ddev mysql
When to use itUse for read-only inspection or a carefully reviewed local query.
04

Step 4: run Composer and Magento commands

DDEV wrappers use the project’s container versions, so the host does not need a matching PHP or Composer installation.

Install locked dependencies

Installs the exact dependency versions recorded in composer.lock.

ddev composer install
When to use itUse after cloning a repository that already has a lock file.

Review a package change

The first command previews dependency resolution; the second applies it after review.

ddev composer require <vendor/package> --dry-run
ddev composer require <vendor/package>
When to use itReplace the placeholder with an approved package name and commit both Composer files.

Check Magento status

Reports deployment mode, cache types, and indexer state without changing data.

ddev magento deploy:mode:show
ddev magento cache:status
ddev magento indexer:status
When to use itRun these checks before deciding whether a cache clean, compilation, or reindex is needed.

Apply Magento database updates

Applies module schema and data changes, then removes application cache entries.

ddev magento setup:upgrade
ddev magento cache:clean
When to use itUse after enabling a module or deploying code that contains setup changes.
CautionBack up first and use maintenance mode for a production deployment.
05

Step 5: remove a local project safely

Stopping is reversible; deleting a project’s managed data is not. Keep the backup outside the project directory if the directory may also be removed.

Back up and stop

Creates a last portable database dump and stops the current project.

ddev export-db --file=final-backup.sql.gz
ddev stop
When to use itUse before archiving or removing a local environment.

Delete the DDEV project

Starts DDEV’s project deletion flow and asks for confirmation.

ddev delete
When to use itUse only after checking ddev describe and preserving anything needed.
CautionDestructive: verify the project name and backup before confirming.
REF

Further reading

Related OpsinTech solutions
ServiceE-commerce Development ServiceCustom Software ServiceManaged Web Hosting & Cloud