Set up local development with DDEV

Set up local development with DDEV

On Windows for Drupal or other PHP project

·

3 min read

In the process of creating a post about testing, I found that my workflow was so specific that I decided to start from scratch and write a post about how I start new projects. Of course, I'm referring to a PHP project, more specifically Drupal. This post is aimed at intermediate level people who have dealt with software development before. The content contains a lot of mental shortcuts. However, if you're a newbie, you may also find the following text to be helpful.

Beginnings

Currently I work in Windows environment, but all of the programs I use have their counterparts in other systems. Nevertheless, working in Windows has its pitfalls.

We are installing Docker and Docker Desktop on Windows. Naturally you need WSL - Linux subsystem, otherwise I can't imagine it. In Windows Store we buy free Ubuntu 20. For a nicer look of our terminal I recommend Windows Terminal. It can be customized just like VSCode, with a configuration file. You can also "buy" it from the above Store for free.

Basically, you are now ready to choose the right tool to work with Drupal. There are a few solutions, I liked DDEV , but there are also Lando , Docksal , Woodby's containers and others.

WSL and DDEV

Now go back to Windows for a moment and install DDEV. The installation instructions are a detailed 20 or so steps that can be completed using any Windows terminal.

If you are already determined to build Drupal as I was - DDEV has detailed instructions to run new Drupal instance straight from inside its containers.

Once you have successfully installed DDEV go into your project directory and start following the DDEV instructions. Run ddev config. The system will ask you for the next configuration steps. If you used the composer command, just remember to point to the correct directory where the index.php file is located. In this case it will be ./web. After the configuration is done, type ddev start and watch the magic happen.

Difficulties?

What did I find difficult? Not the steps of installing more tools, but understanding in which layer, which containers are used.Whether in Windows or in WSL. In the end it turned out that these systems are connected to each other after all. As an exercise I suggest to run DDEV related commands inside WSL with Windows Docker Desktop on and off.

Advantages

Even though you already have php and composer in WSL, is it worth to continue using docker and ddev I won't write too long about it. I'll just list a few advantages that come to mind:

  • choice of any php version as well as servers
  • configured tools related to php , as well as to the framework
  • browser friendly address and ssl certificate automatically
  • export/import of database
  • ease of extending with additional services/containers

Summary, what next?

DDEV is the salt of the development earth. Anyone who happily manages to configure this tool to completion will feel free to set up new projects and will be able to run new scripts routinely with each new project.