TransWikia.com

Craft 3 - Recommended development environment for Windows?

Craft CMS Asked by Kenny Bones on February 24, 2021

I was wondering what people who are developing on Windows 10 are using as webserver environment in 2018? I have had ok results previously using ampps, but I’m having a lot of problems with Craft 3 as of lately. With 500 internal server errors etc. Also, I’m developing on several PCs, syncing the projects with Git.

A friend of mine recommended Laravel Valet and homestead, but he’s on Mac. And installation on Windows seems to be a lot trickier. I’ve tried Mamp too, but have really bad experience with that one.

4 Answers

First of all, I am also a Mac user. But these should be available for Windows too.

Start reading about virtualization. So, you won't install the web server directly on your machine but on a virtual box installed on your machine.

A good starting point could be vagrant (which is becoming a bit antiquated more and more, but which is still worth a try since it's working like a charm).
What's getting more and more into many developers' focus is docker. Many of my customers have been introducing it in their developer teams the last years.

Hope that helps. It's a lot to read though…

Correct answer by Arvid on February 24, 2021

Virtualization is a good idea. This way you can easily replicate your environment on different machines.

I would recommend using Docker as well. I personally use Laradock as development environment. But you could use other or build your own. Which I don't recommend for beginners.

So here is how to start: Install Docker, install Docker Compose, download Laradock, configure it and start MySQL and Nginx/Apache. PHP starts automatically.

Note: When you set up your DB connection in Craft's config remember it is not localhost but mysql. Because this is the name of the running MySQL container.

Answered by Johannes on February 24, 2021

I've had a bit of experience with development environments on Windows and it can be a little bit tricky compared to macOS or Linux, because ultimately the Windows filesystem tends to be a problematic for virtualised setups, which I'll explain in more detail below.

First I would say you want to use virtualisation despite my initial statement above. No one should be having to locally configure any form of dev environment these days, messing around with config files etc. MAMP while it does provide GUI and easy way to tweak it, no one has time for that. You ideally want to have a repeatable and easy one command provision process, where all of this is done for you. You want to be able to completely tear down your dev environment and be able to rebuild it in a matter of minutes not hours.

I've tested Vagrant, Nanobox and more recently Docker on Windows. I would recommend Docker because of it's WSL2 ties now. Previously Docker on Windows relied on Hyper-V but now with WSL support (Windows Subsystem for Linux) Docker becomes more attractive and much lighter weight. Because Docker and WSL are tied to the same Linux kernel running within Windows (Yes Windows has a Linux kernel running inside itself now!) meaning performance wise you'll get much better response times from apps than Vagrant or Nanobox can ever achieve. I found Craft 3 to be horribly slow (even with dev mode off) and I'm afraid it is combination of the VM abstraction layer and the Windows filesystem (it sucks for VMs).

Vagrant and Nanobox both struggle because they require a full VM layer pointing to a Windows filesystem mountpoint, this is where your dev environment is hurt on Windows. The Windows filesystem is a pain in the arse when virtualisation is concerned. You will find issues with certain tools i.e. npm with symlinks and many other Windows specific stuff. There's even been specific issues directly impacting Yii2, which did get fixed, but just shows you that Windows can be evil: https://github.com/craftcms/cms/issues/4355

Docker has the advantage of WSL support and having the concept of containers. So think all the services needed like Apache/nginx (webserver), MySQL/Postgres (database backend), PHP-FPM etc, these can all be in their own containers rather than a single VM in comparison. This has the advantage of being able to swap out or change only certain elements when needed. Example: Fancy switching from Apache to NGINX? Easy, just change you web server container. Want to go to Postgres instead of MySQL? Cool, just switch your DB container.

With Docker, you can literally script the entire process with a docker-compose.yml and Dockerfile to automate the build and provisioning of a development environment. There are also great resources from the community around Docker. Even Pixel and Tonic have official purpose build docker images for Craft CMS 3 development.

https://github.com/craftcms/docker

The documentation on how to use them is a little lacking currently, but there's also an excellent walkthrough from Andrew Welch around a complete walkthrough of Docker environment: https://nystudio107.com/blog/an-annotated-docker-config-for-frontend-web-development, other Craft CMS developers have shared their Docker setups as well. A lot of them share the same common foundation, but may differ in some areas depending on requirements.

The end result, you can literally run one command docker-compose up and everything else is provisioned for you. So that's why I'd recommend Docker. While it is a VM like Vagrant and Nanobox, it's about as lightweight as it can get, coupled with WSL2, I'm pretty sure it's going to be the fastest environment as well.

The alternative would be running an environment on the host directly without virtualisation to avoid issues with volume mounts and such, this however puts more liability on yourself to configure things however, which as per my original statement, nobody has time for that! But you could even use IIS which is the native web server for Windows.

Answered by James White on February 24, 2021

I just use the included IIS on Windows 10 for development. Install MySQL and PHP and all runs fairly smoothly.

Just recently recently configured this on a new Win10 machine and made a note of another couple of points:

  1. Make sure that IIS_IUSRs has full permission to: c:WindowsTemp and the directory where you will hold your development websites.

  2. After up and running if you try to update a plugin within the Control panel you might get a curl error. This should resolve it: https://martinsblog.dk/windows-iis-with-php-curl-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate/

All running smoothly now!

Answered by mmc501 on February 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP