DDEV and Craft CMS Quick-Start Guide
It's more likely your immediate usage of DDEV will be converting existing projects from bespoke local environments.
It’s more likely your immediate usage of DDEV will be converting existing projects from bespoke local environments – where every developer on your team is doing their own local setup – to a local development environment that is uniform across the team for the project, and dictated by the project.
Let’s look at how we can take an existing Craft CMS project and rehome it in DDEV for local development. The end result will be a localhost development environment that can be stored in a config file and saved as part of the project codebase (and be version controlled). Then anyone who comes behind me and uses this project, will only have to run git clone
and then ddev start
to get up and running.
I’m going to rehome the Craft CMS Starter Blog project to use DDEV. The Starter Blog is an official repository from the Craft CMS team that is the result of the tutorial in the documentation.
I chose this because it doesn’t have any DDEV configuration in it yet and it’s an existing project. My copy of the project already has a database, of which I have an export so I can import it.
I already have the project repository cloned locally and ready for a local development environment. I also have a database export waiting in the wings.
I also already have DDEV installed and working.
The next step is to configure the project with DDEV.
Inside the project directory, we run ddev config
just like we would for a new project. But this time we’re not start a new project, we’ll setting up an existing one.
cd starter-blog/
ddev config --project-type=craftcms
Let’s start up the DDEV containers for this project and then update our project to support DDEV.
ddev start
Since I just cloned this repository, I need to download the Composer dependency packages. To do that, we’ll use the composer
subcommand in DDEV:
ddev composer install
Next, we need to import our database. Out-of-the-box, DDEV supports TablePlus, a very nice database management app. It is a paid app but I use it so much that it has more than paid for the license fee in time saved and usefulness.
Running the command
ddev tableplus
will open up the TablePlus app, if it’s installed, and connect to the database for the DDEV project you’re currently working in. Pretty neat, right?
From here we can easily import a database SQL file into our project.
We can also use the DDEV command import-db
to import the database export into our project.
ddev import-db
It will prompt us for the path of the database file we want to import, and then import the database.
Provide the path to the database you wish to import.
Pull path: /Users/ryan/Desktop/craft-blog.sql
193KiB 0:00:00 [ 795KiB/s] [=========================>] 100%
Project type has no settings paths configured, so not creating settings file.
Successfully imported database 'db' for starter-blog
Existing database 'db' was dropped before importing
And now we’re all set with a project on DDEV! The next step would be to commit the .ddev
hidden directory to our Git repository and push it up to the remote repository. You definitely do not want to ignore that directory if you plan to get the full benefit of DDEV.
DDEV and Craft CMS Quick-Start Guide is made up of the following videos: