Drupal Training 1: Local Development Environment
DDEV is the most popular local development environment for Drupal. Here's an outline of how to use it, and a minimum of what should be covered in a training module about using DDEV with Drupal.
DDEV is a powerful tool for local web development, particularly useful for PHP-based applications like Drupal, WordPress, and TYPO3. It simplifies environment setup and project management using Docker containers. Here is a basic guide for setting up and using DDEV.
Installation
- Ensure Docker/Orbstack or similar is installed and running on your system.
- Install DDEV by following the instructions on the official DDEV documentation.
Project Setup (General)
- Create a Project Directory: Make a new directory for the project or navigate to an existing one.
- Initialise DDEV: Run
ddev configin the project directory. The command will prompt for the project type (e.g., drupal, wordpress) and document root. - Start DDEV: Execute
ddev startto start the environment. DDEV will automatically create the necessary Docker containers. - Access the Project: Visit the local URL provided by DDEV. Typically, it will be in the format
http://projectname.ddev.site.
Project Setup (LocalGov Drupal)
- Get the LGD Project via composer.
- Run
ddev startto start the project. - Run
ddev composer installto get all the dependencies. - Run
ddev drush si localgov -yto install a new version of LGD orddev import-db -f /path/to/database.sqlif you already have a copy of the site's database.
Database Management
DDEV provides easy access to the project's database:
- Use
ddev sshto enter the container's shell. - Run commands like
mysqlto interact with the database.
Common Commands
- Start Services:
ddev start - Restart Services:
ddev restart - Stop Services:
ddev stop - Import Database:
ddev import-db --file=database.sql.gz - Export Database:
ddev export-db --file=database.sql.gz - Drush:
ddev drush <drush command>e.g.ddev drush cr - Composer:
ddev composer <composer command>e.g.ddev composer install - Destroy Project:
ddev delete(removes containers but keeps the codebase)
Troubleshooting
If encountering issues, check logs using ddev logs or rebuild the project using ddev stop --unlist && ddev start.
Further Learning
For more advanced configurations, refer to the DDEV documentation for in-depth tutorials and customised settings. This resource provides detailed guides on using additional features like HTTPS support, additional services, and more.
Join the "Something nice ..." newsletter
The full title is "Something nice, something quirky, something else".
I send an email once a week with something nice, something quirky, and something else that I think is interesting (all with a web development theme, of course).