Develop for Drupal & Other Web Applications on Windows!

Develop on Windows for Drupal and other Web Projects!
A step by step of how I got my windows environment setup!

For the past 6 years, I've been a developer using a MacBook as my local machine. I've been in the camp for some time that Windows just wasn't the right platform for Web development, especially for PHP applications and frameworks. They were slow, not very compatible, and the underlying technology just didn't match up with how non Windows IIS Servers worked or operated. And back then, containers for development on Windows were a hit and miss.

Today, I'm very, VERY happy to say that not only is Windows much easier to develop on, it might be the solution I would prefer, granted all of the other perks that come along with a Windows machine.

But how do you setup a Windows machine to do any kind of development? Below are the steps I've taken to get not 1, but 3 different machines up and running with Windows 11, Docker Desktop, DDEV, and NPM / Node!

Step 1: Verify your BIOS and Windows Environment is Ready

Depending on your CPU type, you'll need to make sure that within your PC's BIOS you have the Intel Hyper-Threading on if you have an Intel CPU, or for AMD you have AMD SMT (Simultaneous Multithreading) turned on. When your PC is booting up or restarting, press the appropriate key to access your BIOS. This key is usually F2, F5, DEL, ESC, or something along those lines. You should see on the monitor what it is when your PC is starting up. Once in to your BIOS configuration, you'll want to locate your Processor Options and enable one of the appropriate options above. Save your BIOS configuration.

Note: If your machine is relatively new (2022 or newer), you might not need to do this, as from what I've seen, this is already enabled in your BIOS.

Once your BIOS is fully set, there are a couple of additional options you need to turn on in Windows itself before continuing on further. In your Windows Search, search for "Turn Windows features on or off", and select the appropriate option. You should get a window similar to this one here:

You will want to make sure that the following options are turned on:

  • Windows Subsystem for Linux
  • Virtual Machine Platform
  • Hyper-V (For Intel CPU's only)

If you turned any of these on, save and reboot.

The final part in Step 1 is to enable Developer Mode. Open your Windows Settings, search for 'For developers', and turn on 'Developer Mode'.

Step 2: Enable Windows WSL

Windows has a very good documentation on how to enable WSL (Windows Subsystem for Linux), but if for some reason it isn't showing up, or it has changed, I've documented the steps below:

Open PowerShell or Windows Command Line in administrator mode.

Type in wsl --install

It'll ask you to setup a Linux username and password. They do not need to be the same as your Windows login.

Once the installation is all done, you'll be asked to reboot.

Once you reboot, your system will continue to finish the Linux / Ubuntu setup. Once it is all done, close out any windows open, and then re-launch PowerShell or Windows Command Line as an administrator.

On the command line, you can then access the Linus Distro by simply typing wsl. Once in there, you'll be in the Linux subsystem, and you can perform many / all the standard commands used by Linux.

Note: You can also do some Linux commands in Windows by adding wsl in front of the command.

Example: wsl ls -la to get yourself a look at your current directory structure in a neat and orderly fashion within PowerShell or Windows Command Line!

Step 3: Setup PHP in Windows WSL

Go into the WSL, and you want to run the following command: sudo apt update && sudo apt upgrade. Follow the prompts, then you will want to run the following commands:

sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update

This will add the third-party repository that is widely used for Ubuntu and Debian distributions of PHP. Once this is done, you can install PHP with the command below:

sudo apt install php8.3

Note: If you want a different version or PHP, simply replace the 8.3 with the version number you want.

Once installed, you can verify by running php -v

You can also install optional PHP extensions by running sudo apt install php8.3-{extension_name}. I have found that at least having the php8.3-xml extension installed has helped greatly

Step 4: Setup Docker Desktop, DDEV, and Lando

Note: Before starting this step, if you have ANY Anti-Virus software running, turn it off for this step only. I have found that because of how these software install, especially DDEV, your antivirus software will most likely detect and halt this, thinking it is malicious.

First - Download and install Docker Desktop. If you are on an AMD CPU, use the link in the Download list that is specifically for AMD 64. If you are on an Intel, you will need to navigate through their instructions to find the x86_64. It took a little while for me to find this, so here's the link to the download for you!

When you are installing it, be sure to check on that you want to use the WSL backend.

Once Docker is installed and is running, head over to DDEV and follow their instructions. Since we have already installed WSL, you can skip their first step.

After the installation of DDEV is done, close out your terminal and re-open it, and then run ddev -v to verify that DDEV has been installed.

Now we can then install Lando! Head over to Lando's documentation here and follow their on-screen instructions.

Once Lando is installed, restart your PC.

Step 5: Setup SSH

By default, Windows doesn't do SSH all that well. Mostly because the SSH Client (Open SSH) that is installed is old. We need to update this. Head over to this link here to download and install the latest version of the Open SSH Client.

Once that is installed, we also need to make sure that we can run commands such as ssh-add. From the Start Menu of Windows, type and search for 'Services'. Scroll down to and find the OpenSSH Authentication Agent. If it's Startup Type is not Automatic (Delayed Start), right click on the name of this service and select 'Properties'. Change the Startup Type to Automatic (Delayed Start) and click OK.

Step 6: Setup Git

Getting Git on your Windows machine is very easy. Making sure it is fully configured can be a bit tricky, but once done, you're good to go! First, head over to the official Git website and download the package for Windows. Install the package and follow the onscreen instructions. I mostly keep with the recommended settings, and for the text editor, I select Windows Notepad.

Once installed, there are some global configurations I add to make sure that I do not run into any problems with large repositories. An example of the errors I've ran into can be seen in this Stack Overflow thread here. And while the answer it has can be a solution, it isn't always the full-proof solution. What I have found is that if I edit the global config by running the following command git config --global --edit in PowerShell or Windows Command Line, and inserting the following configuration:

[core] 
	packedGitLimit = 512m 
	packedGitWindowSize = 512m 
[pack] 
	deltaCacheSize = 2047m 
	packSizeLimit = 2047m 
	windowMemory = 2047m

Save the configuration, and this should help avoid errors from cloning extremely large repositories (or even repositories with many commits to it).

Step 7: Setup NVM and Node.js

This here might be optional, depending on what you are needing to work on, but since I do a lot of both backend and frontend development, I find this to be extremely helpful. My guide to getting all of this installed was the documentation from Microsoft, as it was very nice and straight-forward! First, we will install NVM for Windows. It's a nice executable, and it installed without any issues. Once this is installed, head over to Node.js main website, and we want to download and install using their Prebuilt Installer. I found that this caused the least amount of issues, and was easier than the command line to do so.

Step 8: Begin Developing!

Once this is all done, we are ready to develop! But, what about the necessities of modern Drupal like Composer or Drush?! To put it quite simply, our containers through DDEV or Lando handle all of that for us! So what I would do is start a new project with DDEV, and run Composer inside of DDEV. (Example: ddev composer install). The same thing with drush commands.

Now you might be asking yourself: self - why did we install PHP in WSL when our Docker containers have PHP already fully installed and configured?! The answer to that is - depending on your cloud hosting platform, you might need to run 3rd party PHP applications or batch scripts outside of the docker containers, but inside a Linux distro.

There are other applications that I love to use for development, including GitKraken, JetBrains IDE's (PHPStorm and WebStorm), and my all-time favorite GUI SASS and JS Compiler, Prepros! With all of these tools and this setup, developing on a Windows machine has been the same experience for me as I was developing on a MacBook.