This article aims to assist BBD colleagues in the installation and familiarization of DDEV for their local development. The focus here is on providing step-by-step instructions for setting up a Drupal project locally using DDEV.
Why docker?
Docker has gained significant popularity due to its advantages, including portability, consistency, and scalability for deploying applications across diverse environments. At Big Blue Door, we advocate the use of Docker to ensure the following benefits:
- Consistent Development Environments: Docker ensures that all developers share the same setup on their localhost.
- Efficient Project Setup: With Docker, setting up a new project becomes swift and hassle-free, eliminating the need to install each web application individually.
- Minimized Deployment Issues: Docker helps in reducing side effects or unexpected errors when deploying to development, staging, and live environments.
DDEV or Lando?
When it comes to setting up a Drupal project, two prominent tools, DDEV and Lando, stand out. The choice between them is subjective, and individuals can select the Docker-based application that best suits their preferences. Personally, I favour DDEV for its association with the NOT-FOR-profit organization "The DDEV Foundation" while Lando is affiliated with the FOR-profit organization "Lando System, Inc."
Instructions
- Go to the DDEV site and follow their instructions to install DDEV: https://ddev.com/get-started/
Go to BBD Git repos, and clone the Drupal project that we need to set it up locally:
git clone project_url
Go to the project folder, then start DDEV:
ddev start ddev config –-auto ddev composer update ddev config –-auto // at this point, DDEV will recognise that this is a Drupal project. ddev restart
Request a copy of the DB, then import it
ddev import-db < db.sql
Check .ddev/config.yml and make sure all the configurations are correct:
type: drupal9 docroot: web php_version: "8.1"
Insert at the end of this file web/sites/default/settings.php for local development:
$settings['config_sync_directory'] = '../config/sync'; $config['system.logging']['error_level'] = 'verbose'; // hide|some|all|verbose $config['system.performance']['cache']['page']['max_age'] = 0; $config['system.performance']['css']['preprocess'] = FALSE; $config['system.performance']['js']['preprocess'] = FALSE;
Duplicate web/sites/default/default.services.yml to web/sites/default/services.yml and enable twig debug mode:
debug: true auto_reload: null cache: false
To set up other CMS, please check here
Other extensions
Install phpmyadmin
ddev get ddev/ddev-phpmyadmin && ddev restart
Install Solr: https://github.com/ddev/ddev-drupal9-solr
ddev get ddev/ddev-drupal9-solr && ddev restart
- Other addition servers: https://ddev.readthedocs.io/en/latest/users/extend/additional-services/
Useful tips
Enable xdebug
ddev xdebug
Enable xhprof Profiling
ddev xhprof
Save/Restore DB
ddev snapshot --name=db_name ddev restore
References
- DDEV official site
- Lando official site
- DDEV being considered as the "official" Drupal development environment
- Document using DDEV as the recommended Drupal local development environment
- DDEV get started
- DDEV cms quickstarts
- DDEV install Solr
- DDEV addtional services
- DDEV step debugging with Xdebug
- DDEV xhprof profiling
- DDEV database management