Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Drupal 8 Development on Windows - Best Practices?

Parent Feed: 

Over the past several weeks, I've been working with three of the more well-known Docker-based local development environments that involve a Drupal focus: Docksal, DDEV, and Lando. The goal is to not only to figure out which one I prefer, but also to figure out which our two long-form online Drupal training classes should potentially standardize on.

Docksal logoOur classes are often comprised of folks from all different technical backgrounds, so it is important that we not only teach them tools that Drupal professionals use, but also something that folks of myriad of skill levels can easily consume. Perhaps most importantly, while the majority of our students are on Mac OS X, we still have a consistent number of students using Windows, so any solution we recommend should work similarly on all platforms.

As a Mac OS X user myself, it is important to me that I can instruct our Windows-based students without having to resort to a separate set of instructions. To that end, I have an actual Windows 10 Pro machine (not a virtual machine) that I've been using to evaluate these local development environment options. 

I've decided to focus on DDEV, Lando, and Docksal because I really like the idea of Docker-based containers; being able to customize your local development environments to each project has too many advantages to ignore. Also, as one of our classes is Pantheon-focused, Lando's Pantheon integration is a very important differentiator. 

Requirements

DDEV logoI have a basic set of requirements that a local development environment should be able to handle. These requirements are probably focused more on our introductory Drupal Career Online course, but I'd like to be able to recommend the same solution for any of our courses.

  • Run Composer commands (including create-project). It doesn't matter to me if this command is run on the local OS or in a container, as long as it works with a minimum of fuss. The "create-project" command can be a bit tricky on Windows - keep reading to find out why.
  • Run Git commands both on the local OS and in the container. 
  • Be able to get up-and-running with a minimum of downloads. On Mac OS X this isn't much of an issue with Terminal, Git, and PHP preinstalled, but on Windows it is a different story.
  • Be able to get up-and-running with a minimum of "extra" configuration. Granted, once you're comfortable on the command line adding something to your local PATH isn't a big deal, but for folks new-ish to the command line, it can be a significant hurdle. 
  • Have a Linux-based command line interface (to use commands like cd, ls, cat, etc...)
  • Be able to easily (zero configuration) edit text files on the command line (nano or pico).
  • Be able to modify file permissions and ownership from the command line (chown and chmod).
  • Be able to run Drush, Drupal Console, and all of the other Drupal-y things that a professional developer should have.

I am very cognizant that my requirements are probably represent the lower-end of the Drupal skill-level spectrum, but I feel these requirements are a reasonable starting point.

Potential solution

Microsoft Windows 10 logoOver the past few weeks, I think I've installed, uninstalled, and reinstalled various combinations of Lando, Docksal, and DDEV as well as various command line shells (Babun, Cmder, PuTTY, Cygwin) and the Windows Subsystem for Linux at least a dozen times on my Windows machine. All this in an effort to figure out what is the best combination of tools to satisfy the requirements. At the current moment, I'm circling around recommending Lando and Cmder on Windows (Lando requires Windows 10 Pro with Hyper-V enabled) - both are easily installed with no extra configuration necessary to get almost everything working. 

Upsides

Lando logoWith just Lando and Cmder installed almost all of the requirements are met. I can use Git to clone a site down to my local, get it up and running in Lando and get to work.

Downsides

One minor issue is that Cmder doesn't come with nano nor pico for editing text files from the command line. It does come with vim, however (which we all know has a steeper learning curve). I can probably mitigate this issue with a little bit of config to have students run a command to open text files in something like Notepad++ or teach some basic vim commands.

The other issue is a bit more serious. With only Lando and Cmder installed, there's no way to run "composer create-project". While Lando makes Composer available in the container, developers don't normally create the containers until they have a code base. This is a bit of a chicken-and-egg issue:

  1. We need Composer to get the new code base.
  2. We need the Lando container to be up-and-running to get Composer.
  3. We need a code base before we start Lando.
  4. (return to step 1 above)

So, I think I know what you're thinking: just install Composer. Well, this isn't as simple as it sounds, as Composer requires PHP, and as far as I can tell, installing PHP on a Windows machine isn't super-straight-forward. Granted, if the developer already has another AMP stack on their Windows machine, the Composer install can be configured to use the php.exe installed with it. 

Docksal actually has a command that allows a developer to run Composer without actually having a set of containers already initialized for the project using the "fin run-cli" command. This utilizes a standalone cli container and completely removes the need to install Composer on the local OS. 

Next steps

So, where does that leave us? I'm not 100% sure, but I wanted to put this out there and get some feedback. Are you a professional Drupal developer that uses Windows as your main OS? If so, what's your setup? Am I missing anything? 

While I often try to steer new Drupal developers towards Mac OS X or Linux, sometimes it is not possible due to corporate policies or even just personal preference. I'd love to be able to teach a solution that provides a professional-level Drupal developer experience to Windows users.

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web