Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidjguru/afd89f31964209e8cb58f2427aeeffbe to your computer and use it in GitHub Desktop.
Save davidjguru/afd89f31964209e8cb58f2427aeeffbe to your computer and use it in GitHub Desktop.
Drupal 8 || 9 - Create, configure and deploy a Drupal installation using DDEV

Quick Deploy of a Drupal 9 Site in a local environment using DDEV: This snippet is gathering some basic tasks with DDEV in order to create, config and then deploy a local Drupal installation. DDEV is a quite interesting development tool for Drupal, based in Docker and Docker-Compose. This tool can facilitate the development of Drupal projects.

Know more about DDEV:

Author

Create and Deploy a new Drupal project

$ mkdir example-drupal && cd example-drupal
$ ddev config --project-type=drupal9 --docroot=web --create-docroot
$ yes | ddev composer create "drupal/recommended-project"
$ ddev composer require drush/drush drupal/admin_toolbar drupal/devel
$ ddev exec drush si --site-name=Example-Drupal --account-name=admin --account-pass=admin -y
$ ddev start && ddev launch

Stop and delete your DDEV configuration and codebase

$ ddev stop 
$ yes | ddev delete -O
$ cd ..
$ rm -rf example-drupal

Operating between active configuration (database) and passive configuration (config files)

Loading the most recent database dump file

Prerequisite: You have a backups folder in path example-drupal/backups at the same level than /web.

$ cd example-drupal
$ latest_dump=$(ls ./backups -ABrt1 --group-directories-first | tail -n1)
$ ddev import-db --src=backups/$latest_dump

Getting an updated database dump file

$ ddev export-db --file backups/db.sql.gz

Using the current date for naming the database dump file

$ date=$(date +"%Y-%m-%d")
$ ddev export-db --file=./backups/db_$date.sql.gz

The most basic operations with config files

From config files to database (passive -> active).

$ ddev drush cim -y

From the database to config files (active -> passive).

$ ddev drush cex -y 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment