Using the
ddev
Command
Type
ddev
or
ddev -h
in a terminal window to see the available DDEV
commands
. There are commands to configure a project, start, stop, describe, etc. Each command also has help using
ddev help <command>
or
ddev command -h
. For example,
ddev help snapshot
will show help and examples for the snapshot command.
-
ddev config
configures a project’s type and docroot, either interactively or with flags.
-
ddev start
starts up a project.
-
ddev launch
opens a web browser showing the project.
-
ddev list
shows current projects and their state.
-
ddev describe
gives all the info about the current project.
-
ddev ssh
takes you into the web container.
-
ddev exec <command>
executes a command inside the web container.
-
ddev stop
stops a project and removes its memory usage (but does not throw away any data).
-
ddev poweroff
stops all resources that DDEV is using and stops the Mutagen daemon if it’s running.
-
ddev delete
destroys the database and DDEV’s knowledge of the project without touching your code.
-
ddev add-on
adds an add-on service.
Lots of Other Commands
-
ddev mysql
gives direct access to the MySQL client and
ddev psql
to the PostgreSQL
psql
client.
-
ddev sequelace
,
ddev tableplus
, and
ddev querious
(macOS only, if the app is installed) give access to the Sequel Ace, TablePlus or Querious database browser GUIs.
-
ddev heidisql
(Windows/WSL2 only, if installed) gives access to the HeidiSQL database browser GUI.
-
ddev import-db
and
ddev export-db
import or export SQL or compressed SQL files.
-
ddev composer
runs Composer inside the container. For example,
ddev composer install
will do a full composer install for you without even needing Composer on your computer. See
developer tools
.
-
ddev snapshot
makes a very fast snapshot of your database that can be easily and quickly restored with
ddev snapshot restore
.
-
ddev share
requires ngrok and at least a free account on
ngrok.com
so you can let someone in the next office or on the other side of the planet see your project and what you’re working on.
ddev share -h
gives more info about how to set up ngrok.
-
ddev xdebug
enables Xdebug,
ddev xdebug off
disables it, and
ddev xdebug status
shows status. You can toggle Xdebug on and off easily using
ddev xdebug toggle
.
-
ddev xhprof
enables xhprof,
ddev xhprof off
disables it, and
ddev xhprof status
shows status.
-
ddev drush
(Drupal and Backdrop only) gives direct access to the
drush
CLI.
-
ddev artisan
(Laravel only) gives direct access to the Laravel
artisan
CLI.
-
ddev magento
(Magento2 only) gives access to the
magento
CLI.
-
ddev craft
(Craft CMS only) gives access to the
craft
CLI.
-
ddev yarn
and
ddev npm
give direct access to the
yarn
and
npm
CLIs.
-
ddev cake
(CakePHP only) gives direct access to the CakePHP
cake
CLI.
Node.js, npm, nvm, and Yarn
node
,
nodejs
,
npm
,
nvm
and
yarn
are preinstalled in the web container. You can configure the default value of the installed Node.js version with the
nodejs_version
option in
.ddev/config.yaml
or with
ddev config --nodejs_version
. You can also override that with any value using the built-in
nvm
in the web container or with
ddev nvm
, for example
ddev nvm install 6
. There is also a
ddev yarn
command. (Note that since
nodejs_version
configuration can now specify any
node
version, including patch versions, it’s preferred to using the less robust
ddev nvm
way of specifying the
node
version.)
In addition to the
commands
listed above, there are lots of tools included inside the containers:
-
ddev describe
tells how to access
Mailpit
, which captures email in your development environment.
-
Composer, Git, Node.js, npm, nvm, symfony, and dozens of other tools are installed in the web container, and you can access them via
ddev ssh
or
ddev exec
.
-
ddev logs
gets you web server logs;
ddev logs -s db
gets database server logs.
-
sqlite3
and the
mysql
and
psql
clients are inside the web container (and
mysql
or
psql
client is also in the
db
container).
Exporting a Database
You can export a database with
ddev export-db
, which outputs to stdout or with options to a file:
To import static file assets for a project, such as uploaded images and documents, use the command
ddev import-files
. This command will prompt you to specify the location of your import asset, then import the assets into the project’s upload directory. To define a custom upload directory, set the
upload_dirs
config option. If no custom upload directory is defined, the default will be used:
-
For Backdrop projects, this is
files
.
-
For Drupal projects, this is
sites/default/files
.
-
For Magento 1 projects, this is the
media
directory.
-
For Magento 2 projects, this is the
pub/media
directory.
-
For Shopware projects, this is the
media
directory.
-
For TYPO3 projects, this is the
fileadmin
directory.
-
For WordPress projects, this is the
wp-content/uploads
directory.
Other project types need a custom configuration to be able to use this command.
ddev import-files
supports the following file types:
.tar
,
.tar.gz
,
.tar.xz
,
.tar.bz2
,
.tgz
, or
.zip
.
It can also import a directory containing static assets.
If using a Tar or ZIP archive, the archive should contain
only the files inside the files directory
. For example in a Drupal site with files at
sites/default/files
, the archive should only contain the contents of the
files
directory; it should not contain a single
files
directory. To do this with the
tar
command,
cd
into the directory and create the archive there. An example Tar file creation is:
If you want to use
import-files
without answering prompts, use the
--source
or
-s
flag to provide the path to the import asset. If you’re importing an archive, and wish to specify the path within the archive to extract, you can use the
--extract-path
flag in conjunction with the
--source
flag. Example:
ddev import-files --source=/tmp/files.tgz
When multiple
upload_dirs
are defined and you want to import to another upload dir than the first one, use the
--target
or
-t
flag to provide the path to the desired upload dir:
ddev import-files --target=../private --source=/tmp/files.tgz
See
ddev help import-files
for more examples.
The project database is stored in a Docker volume, but can be snapshotted (and later restored) with the
ddev snapshot
command. A snapshot is automatically taken when you run
ddev stop --remove-data
. For example: