DDEV and Craft CMS Quick-Start Guide

Creating a New Craft CMS Project on DDEV

Let's imagine we're kicking off a new client project and we're excited about spinning up a brand new Craft CMS installation. We do it correctly by getting a standard local development environment setup, too.

As of ver­sion 1.21.2, DDEV sup­ports a Craft CMS project type. A project type in DDEV offers addi­tion­al com­mands and sup­port for a CMS or frame­work. The Craft CMS project type speeds up the cre­ation of new Craft CMS projects, espe­cial­ly the .env file and the default data­base settings.

You’ll get the best expe­ri­ence using DDEV and Craft if you use the project type and the com­mands in the order I show them.

First, we will cre­ate a project direc­to­ry and then cd into that directory.

mkdir yellowstone
cd yellowstone

Next, we’ll run ddev config to cre­ate the project:

ddev config --project-type=craftcms --docroot=web --create-docroot

We are pass­ing in the project type as craftcms, so DDEV knows to han­dle the set­up process specif­i­cal­ly for Craft and the doc­root of web and that DDEV should cre­ate the doc­root via --create-docroot.

We can start the DDEV project, spin­ning up the nec­es­sary Dock­er con­tain­ers to install Craft CMS.

ddev start

Next, we’re ready to cre­ate our project using Com­pos­er. DDEV has a composer create com­mand, sim­i­lar to composer create-project. We’ll pass along some options to default to yes, not run scripts.

ddev composer create -y --no-scripts craftcms/craft

With the con­tain­ers up and run­ning, we can now run craft install through ddev and start the Craft instal­la­tion process.

ddev craft install

Once Craft is installed, we can launch it in the brows­er via ddev launch or nav­i­gate to the host­name set up for the project.

If you’re ever unsure of your project’s DDEV set­tings, you can use the ddev describe command:

ddev describe

┌───────────────────────────────────────────────────────────────────────┐
│ Project: ddev-test ~/training/ddev-test https://ddev-test.ddev.site   │
├────────────┬──────┬───────────────────────────────┬────────────────── ≈
│ SERVICE    │ STAT │ URL/PORT                      │ INFO              ≈
├────────────┼──────┼───────────────────────────────┼────────────────── ≈
│ web        │ OK   │ https://ddev-test.ddev.site   │ php PHP7.4        ≈
│            │      │ InDocker: ddev-ddev-test-web: │ nginx-fpm         ≈
│            │      │ 443,80,8025                   │ docroot:'web'     ≈
│            │      │ Host: localhost:64434,64435   │                   ≈
├────────────┼──────┼───────────────────────────────┼────────────────── ≈
│ db         │ OK   │ InDocker: ddev-ddev-test-db:3 │ MariaDB 10.3      ≈
│            │      │ 306                           │ User/Pass: 'db/db ≈
│            │      │ Host: localhost:64433         │ or 'root/root'    ≈
├────────────┼──────┼───────────────────────────────┼────────────────── ≈
│ PHPMyAdmin │ OK   │ https://ddev-test.ddev.site:8 │                   ≈
│            │      │ 037                           │                   ≈
│            │      │ InDocker: ddev-ddev-test-dba: │                   ≈
│            │      │ 80,80                         │                   ≈
│            │      │ `ddev launch -p`              │                   ≈
├────────────┼──────┼───────────────────────────────┼────────────────── ≈
│ Mailhog    │      │ MailHog: https://ddev-test.dd │                   ≈
│            │      │ ev.site:8026                  │                   ≈
│            │      │ `ddev launch -m`              │                   ≈
├────────────┼──────┼───────────────────────────────┼────────────────── ≈
│ All URLs   │      │ https://ddev-test.ddev.site,  │                   ≈
│            │      │ https://127.0.0.1:64434,      │                   ≈
│            │      │ http://ddev-test.ddev.site,   │                   ≈
│            │      │ http://127.0.0.1:64435        │                   ≈
└────────────┴──────┴───────────────────────────────┴────────────────── ≈

DDEV and Craft CMS Quick-Start Guide is made up of the following videos: