Skip to content

Windows Developer Guide

David Upton edited this page Aug 8, 2018 · 22 revisions

Windows Developer Guide

Because Drupal is most commonly installed on a Linux servers, City of Boston Boston DoIT do not recommend using Windows® as a developer machine due to the increased difficulty in emulating the most common Drupal production web-server.
However, if you have no alternative, or harbor an unquenchable desire to use Windows® then the following best-practices and instructions should get you headed in the right direction.
There are 3 strategies:

  • A: Develop on Windows host - jump to this,
  • B: Develop in Linux (or Mac) OS installed within a Virtual Machine on the Windows host - jump to this,
  • C: Develop in Linux using a dual boot on the host machine - jump to this.

A: Develop on Windows host

This is the most complicated solution to setup, but allows the developer to use any windows-based tools desired to manage the Drupal code-base and databases.

General Development Strategy Described

The git repo is cloned to a local Windows folder on the Windows host. This repo folder is mounted into a Linux (Ubuntu) Docker Container (like a VM). Docker manages the virtualization and the container contains all the apps and resources required to host and manage the website locally for development purposes. Git commands are run either from the Windows host, or from the container. Lando (a container manager tool) provides a "wrapper" whereby commands (e.g. Docker, Lando, Git, Phing, Drush, Composer, SSH etc) are typed into a console on the Windows host, and Lando executes them inside the container.

To be clear, with this strategy:

  • the container hosts the website, and
  • the developer normally changes/adds/removes Drupal files in the Windows folder on the Windows host, and
  • changes to custom Drupal files (i.e. to files in the mounted folder) either on the host or in the container are immediately available to both the host and container without restarting docker or VM's, and
  • the developer normally runs dev tools such as Git, Drush, Phing and Composer in the container, using Lando commands, and
  • the Windows host does not require to have tools other than Docker, Lando and VBox or Hyper-V installed on it, and
  • some developers still like to have git installed on the Windows host so their IDE tools (e.g. PHPStorm) can manipulate the repos directly, and
  • developers' need to interact directly with the container (i.e. via ssh) is minimized, and

Setup local development environment

This installation creates a developer environment suitable for a Linux-based production deployment.
IMPORTANT:
Due to Lando requirements to use Docker CE (not Docker Toolkit), which in turn requires Hyper-V, you:
*NEED to have a Windows 10 64bit Professional or Enterprise version, and *CANNOT use Windows 7 or earlier, and *CANNOT use Windows Home or Home Pro as Hyper-V is required by Lando and does not ship with home versions. These 6 steps are all performed on the host (i.e your Windows®) PC

1. Set up Virtualization

This is required to supply a Linux core which is needed by Docker to generate the necessary containers.

Install Windows Subsystem for Linux (preferred method)

These instructions also depend on having a current version of Windows® 10 (version later than Fall Creators Update and pref build 16215 or later).
To install WSL support, do the following:

  1. Open Windows Powershell as Administrator,
  2. Run Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux,
  3. Restart Windows when prompted.
    Taken from here
Note: Install Linux Distro

DoIt suggest you install the Linux distribution from the Microsoft Store which most closely matches the Linux distro you will use on your production webservers. If you are unsure, install Ubuntu or Debian.

Note: Install Hyper-V

If Hyper-V is not enabled when the Linux subsystem was installed (check by typing Hyper-V in the start menu), then follow these instructions

2. Install Git (optional but recommended)

If you are not using WSL, then Git for Windows provides a bash terminal for the Windows host. Installing Git for Windows is a convenient way to get this, and also gives the developer the option to directly execute git commands (against the repo) from the Windows host.
This step is optional if you use WSL or if you are confident with some other tool to provide a bash style console.
Use Git for Windows from here.
This is a good tutorial to step thru' installation.

3. Install Docker

  • If you are using WSL and have enabled Hyper-V for your virtualization, then use the Docker "community version" from here - this link also guides you through an install.

4. Install Lando

Download the latest Windows .exe installer from here

5. Install IDE/editor

On Windows®, DoIT recommend:

6. Finished: goto Clone repo

Pickup from step 3 on the quick install guide.

B: Develop in Linux (or Mac) OS installed in a Virtual Machine

This solution may be a quick and viable option if you have a powerful Windows machine to use as the host, and are not doing much development which required extensive use of an IDE. Depending on your setup, there may be issues with IPAddress routing, requiring complex configurations.
Note: This method is not used by City of Boston DoIT, the preferred solutions on Windows machines are A or B.

Guidance/Tips

  • For Windows® versions before 10 Fall Creators Update, we recommend that VirtualBox (free from Oracle) is used, and
  • For later versions you should use enable and use Hyper-V within Windows.
  • In the VM, install a Linux distro as close as possible to the production distro you will use, and unless you are very comfortable with the Linux CLI, be sure to install a distro with a GUI.
  • Once the Linux distro is installed, then follow the setup instructions for Linux.

C: Develop in Linux using a dual boot