Skip to content

Category: Technology

PHP Caddy v1.3.4

I just pushed out a new version of PHP Caddy today with a bugfix that should make it a lot more stable.

I have been using PHP Caddy as my primary development environment on my PC at work for the last month or so.  At first it was wonderful – stable, fast, easy, as advertised.  But as I got into the swing of using it, I started running into issues with the PHP FastCGI (php-cgi.exe) process crashing and causing 502 Bad Gateway errors – occasionally at first, but more frequently over time until it was barely usable.  I have no idea what causes it to crash, and I have exhausted my google-fu trying to find a cause or solution, until now.

When I first started building PHP Caddy, I had PHP 7.0 installed, and that’s what I’ve been running since.  This week, as the crash frequency was reaching unbearable levels, I decided to try upgrading to PHP 7.1.  Initially, this didn’t make much difference – the crashing continued.  However, in my continuing search for a solution to the problem, I found a reference somewhere that said that PHP 7.1 had added support for running multiple processes on Windows.  This rang a bell, so I looked into it.

Success!  Setting the environment variable PHP_FCGI_CHILDREN=2 before starting up the PHP FastCGI process, tells php-cgi.exe to spawn multiple processes (3 total), and fixed the stability issues completely.  I have now been running PHP Caddy continuously for the past two days without crashing.

If you are using PHP Caddy and have been experiencing occasional 502 Bad Gateway errors, try upgrading to PHP 7.1 and be sure to run composer global update.

Introducing PHP Caddy

Here’s something I have been working on recently:

PHP Caddy is a tiny PHP development environment for Windows, inspired by Laravel Valet.

No hosts file, no configuration, no frills. Just run it and go write some code.

Why?
In a world where Homestead and Valet exist, this is a good question.  A couple things:

1) Due to the corporate nature of my current job, I work on a PC during the day, so Valet (MacOS only) is not available to me.  At home I get to play with Valet, and it makes daytime me very jealous.

2) While as a developer I have slightly higher privileges on my PC than the average bear, I still do not have full administrator privileges and can’t install everything I want, so some of the Valet for Windows alternatives that provide all the dns niceities of Valet are not available to me.

3) Sometimes a virtualized environment like Homestead is a bit (sometimes a lot) slow on Windows.

So, I built this thing.  I like it a lot.  It runs very fast for me, and makes developing in PHP on Windows a bit more enjoyable.  Maybe you’ll like it too.