Install Craft CMS v5 with one command via DDEV
Tags: ddev, craftcms, php, docker
Published: 2024-01-07 13:03:30

The new major version 5 of Craft CMS will introduce a lot of new features and improvements. See all changes here: [Craft 5 Beta Released](https://craftcms.com/blog/craft-5-beta-released). 

Do you already want to try the new version? It is super simple with [DDEV](https://ddev.com/) - just paste one command into your terminal!

**Update: Craft5 is released - https://craftcms.com/blog/craft-5. The commands in this article are updated for the latest stable v5 version 🎉**

**What is Craft CMS?**

Craft CMS is a flexible Content Management System with an awesome authoring experience (AX) as well as powerful features for developers and designers alike. 2023 was another great year for Craft CMS: [2023 in Review](https://craftcms.com/blog/2023-in-review). There are now  over 8'000 developers registered in [Craft Discord](https://discord.com/invite/uuDFCTX) - according to the latest [State of Craft](https://craftcms.com/events/dot-all-2023/sessions/state-of-craft-2023) talk by Brandon Kelly.

**Requirements**

If you haven't installed a Docker runtime, you might be happy with [Orbstack](https://orbstack.dev/). Other alternatives: [DDEV docs: Docker installation](https://ddev.readthedocs.io/en/stable/users/install/docker-installation/).

Afterwards you can simply install DDEV via homebrew (on Mac):

```
brew install ddev/ddev/ddev && mkcert -install
```

Check if it was successful with `ddev -v`.

For other operating systems see [DDEV docs](https://ddev.readthedocs.io/en/latest/users/install/ddev-installation/) for setup instructions.

**Install CraftCMS v5**

Get the latest CraftCMS v5 version with this one command:

```
mkdir craft5-ddev && \ 
  cd craft5-ddev && \
  ddev config \
    --project-type=craftcms \
    --docroot=web \
    --create-docroot \
    --php-version="8.2" \
    --database="mysql:8.0" \
    --nodejs-version="20" && \
  ddev start -y && \
  ddev composer create -y --no-scripts craftcms/craft && \
  ddev craft install/craft \
    --username=admin \
    --password=password123 \
    --email=admin@example.com \
    --site-name=Testsite \
    --language=en \
    --site-url='$DDEV_PRIMARY_URL' && \
  echo 'Nice, ready to launch!' && \
  ddev launch
```

You will be greeted with the default index template:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xfct5sqks42zknvvi73h.png)

You can also open the backend via

```
ddev launch /admin
```

and login via `admin` and `password123`.

![Craft login](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3h2ywkmt9p3pfpsxx4ft.png)

**Automate it**

You can take this one step further and generate the folder (and therefore project names) dynamically. Thanks very much to [August Miller](https://discord.com/channels/456442477667418113/1199815065327632554/1199821775861710848) for this recommendation!

```bash
TIMESTAMP_FOLDER=$(date +'%Y%m%d-%H%M'); mkdir "craft5-$TIMESTAMP_FOLDER" && cd "craft5-$TIMESTAMP_FOLDER" && \
ddev config \
    --project-type=craftcms \
    --docroot=web \
    --create-docroot \
    --php-version="8.2" \
    --database="mysql:8.0" \
    --nodejs-version="20" && \
  ddev start -y && \
  ddev composer create -y --no-scripts craftcms/craft && \
  ddev craft install/craft \
    --username=admin \
    --password=password123 \
    --email=admin@example.com \
    --site-name=Testsite \
    --language=en \
    --site-url='$DDEV_PRIMARY_URL' && \
  echo 'Nice, ready to launch!' && \
  ddev launch
```

But beware to not fill up your local harddrive too much. Delete DDEV projects with `ddev delete` (or `ddev delete -O` without snapshot) and keep your projects organized with `ddev list`. You can also use `ddev delete -O <project-name>`. 

**Try it out online with GitHub Codespaces**

If you don't want to install Craft CMS v5 locally, you could also launch a new Github Codespace instance here:

- https://github.com/mandrasch/launch-codespace-with-ddev

![Screenshot launch codespace](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su45ujqawdj9aib08voa.png)

Paste the command from above into the terminal:

![Screenshot codespaces terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xilsogbwkn33q1qklov.png)

Open port 8080 (web) in the simple browser or in a new browser tab in the ports section:

![Screenshot codespaces with Craft CMS open](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9i2990dp5e74tne05xjs.png)

Have fun trying Craft CMS v5 out!

**More Resources:**
- [Welcome to Craft - official tutorial](https://craftcms.com/docs/getting-started-tutorial/)
- [craftquest.io: Craft 5 guide](https://craftquest.io/courses/craft-5-guide)
- [spin-up-craft (without DDEV, Docker native)](https://github.com/nystudio107/spin-up-craft)
- [Craft CMS Discord](https://discord.com/invite/uuDFCTX)

**Want to try CraftCMS stable with one command?**

https://dev.to/mandrasch/install-craft-cms-v4-with-one-command-via-ddev-32da