Develop on Windows

Body

This documentation is deprecated.

 

Development on Windows is covered in Windows development environment. It is recommended to use a Docker-based solution such as DDEV or Lando instead of using WSL "directly".

WSL: Windows Subsystem for Linux

Since Windows 10, Microsoft provides the Windows Subsystem for Linux (WSL), which gives access to a Linux virtual machine on your Windows PC. It's fully supported by Microsoft, natively integrated in the OS, and provides a major Linux distribution out of the box.

Install WSL as a standard app through the Windows Store or manually following the official documentation.

Once installed or enabled, clicking on the app icon launches a classic shell window where you can use Linux commands to setup a Drupal project.

The Linux filesystem is available in the Windows Explorer under the path:  \\wsl.localhost\<distro_name>\...

Major IDEs such as VSCode and PhpStorm natively detect WSL's presence and are fully compatible with it and its Linux tools (Git, Docker etc.).

DDEV, Lando and Docksal are also compatible with WSL.

Docker Engine runs smoothly in WSL and is a bit faster than Docker Desktop (which also uses WSL under the hood).

Tips

You could have several distributions running in parallel.

Configuration files

  • %UserProfile%/.wslconfig (on Windows): Use for adjusting the size of WSL, number of vCPUs, RAM, swap etc..
  • /etc/wsl.conf (on Linux): Use for configuring your distro: automount Windows drive, name resolution, systemd etc..

Known limitations

Windows mounted volumes are slow.DO NOT place your code on a Windows path such as /c/... or /mnt/c/...Use a Linux path such as /var/... or /home/$USER/...

Networking with the Windows host is a bit complex. There is no fixed IP other than 127.0.0.1.

Other solutions

If for some reason WSL could not be used, other *nix implementations are available, such as Cygwin, MSysGit toolkit or Gitbash, but these are much more limited environments.

Running and coding with native Windows applications such as WAMP, XAMPP, OSPanel or easyphp is also possible but adds even more limitations such as limited shell, file encoding, line endings, unavailability of Drush, slowness etc..

The real safe alternative to WSL is to use Virtual Machine such as Virtualbox, or Vagrant.

Knowledge Category