DDEV for local development of Drupal 9 and 10

I had a local docker setup running for a while, but since my laptop was stolen, I had to set it up again. It was the perfect opportunity to update the development build and make other changes. While I was reading a tweet by Dries about how easy DDEV was, I thought to myself that I could do it too. Dries mentioned that he updated his website from Docker for Desktop to DDEV in just 15 minutes.

So I was curious :)

First install DDEV, it's easy with homebrew

The Drupal part!

What were the steps I took?

First I downloaded my Drupal 9 repository from gitlab.com. I host the code there.

  1. git clone secrut/yoponline.git
  2. cd yoponline
  3. run ddev config
  4. press enters for name, but for docroot I typed drupal since my codebase has drupal directory which is the docroot.
  5. Then ddev found a codebase and I said drupal9 yes still 9. Will update later! :)
  6. run ddev start

Something about statistics; I said no xD

DDEV starts pulling stuff, it's a kind of magic!

After it's done it says the following:

Successfully started yoponline
Project can be reached at https://yoponline.ddev.site

But... this page gives https issues and if I accept the risk, an # 403 Forbidden by NGINX

But alas, I probabbly need to build the project first? Like with composert? YES YES! Yousa smaaart.

Handy command is given now:

ddev describe Which gives a nice table with info. Neat!

ddev composer install

This started downloading packages, and also asked this:

Do you trust "composer/installers" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json)

I do not trust, but said yes. Read more about it here I think: https://www.drupal.org/project/drupal/issues/3255749

Oh there were three yesses. Oh another one.

Just checked what my new VPS version of Mariadb is:
mariadbΒ  Ver 15.1 Distrib 10.6.12-MariaDB

Got that fur later.

So downloading and scaffolding done?

Scaffolding files for drupal/core:
Copy bla bla...
> DrupalProject\composer\ScriptHandler::createRequiredFiles
Create a sites/default/services.yml file with chmod 0666

Et voila. Code is downloaded.

Now to import Database.

First updated DDeV to this db version of mariadb

ddev debug migrate-database mariadb:10.6

Because using drupal9 setup had 10.4 apparently, probably won;t change much about the experience, but I like the dev environment to mirror live environment as much as possible of course :)

/Users/wonky/Downloads/prod-dump20230419.sql This is the way.

Running db import;
ddev import-db --src=/Users/wonky/Downloads/prod-dump20230419.sql

Successfully imported database 'db' for yoponline

:O Amazing, such wow!

I used a secure copy command to get all files in /files :) And used that as input for local files in DDEV.

scp -r [username]@[example.com]:/path/to/[docroot] /local/path

So then run: ddev import-files

and your local path, in my case it was: /Users/wonky/Downloads/files

Looked like this:

➜  yoponline git:(master) βœ— ddev import-files
Provide the path to the source directory or archive you wish to import.
Please note: if the destination directory exists, it will be replaced with the
import assets specified here.
Path to file(s): /Users/wonky/Downloads/files
Successfully imported files for yoponline

So now we should be done right? DB and Files and drupal installed? Maybe urls now work?

I actually ran ddev start again. and clicked the links.

I now clicked accept risk again, so next up is trying to fix https locally?


So apparantly the security issue is with firefox;

I stopped ddev, and did the mkcert commands agian

ddev stop;

mkcert -install
The local CA is already installed in the system trust store! πŸ‘
Warning: "certutil" is not available, so the CA can't be automatically installed in Firefox! ⚠️
Install "certutil" with "brew install nss" and re-run "mkcert -install" πŸ‘ˆ

➜  yoponline git:(master) βœ— brew install nss

mkcert -install

The local CA is already installed in the system trust store! πŸ‘
The local CA is now installed in the Firefox trust store (requires browser restart)! 🦊

Rebooting firefox, hold on!

So run ddev start again and went to url:

wow... so great.

That was it; I had everything running locally!

The Drupal 9 to 10 updates will now begin!