jdschroeder.ca The personal site of Josh Schroeder

Keeping local web development simple

I’ve spent my entire adult life building websites. Most of the time it’s involved PHP, and so most of the time I’ve needed to find a development server to house it while I was working on it. That’s what I thought, anyways.

Over time, this has meant using tools like MAMP, Acquia Dev Desktop, and Kalabox. I even spent some time digging into Vagrant and Chef to build a Drupal development environment to suit my most common requirements.

More recently, I wanted to make my development environment a little more flexible, allowing me to do some maintenance work with an Expression Engine site, tinker a bit with Symfony, and continue with my usual Drupal work. I wanted to be able to spin up a new site as quickly as creating a new directory.

The solution I came up with has worked pretty well for me, and I was pretty pleased with myself for getting it set up. I have a Ubuntu server running on VirtualBox, and a shared folder that contains all of the sites I’m working on. Each of those is named with a .dev suffix that, thanks to some wildcard virtual hosts and DNS magic, provides a URL for local access. If I create a directory in my shared folder called example.dev, the contents of a web subfolder are then served up at the example.dev domain name.

So I’ve been happily rolling along with that environment on my work and home computers. But then I had to set up a development environment on a new laptop. Suddenly I’m really wishing that I would have written down the steps I’d taken to get it all working. Before getting around to it, though, I had a revelation. I’ve been working through some Ruby on Rails tutorials lately, and one of the key development tools there is the command line rails tools, including rails server, which runs your current Rails app using the bundled Puma web server.

I wanted to spin up a quick Drupal 8 site at work last week to test an idea, and as quick as it is to set up a new site in my development environment, for the simple test that I wanted to run, I wished it was as simple as spinning up a Rails development server (Yes, I know Symfony has console server:run. No, I don’t know why I didn’t think of this before). I was reminded of Drush’s site-install command, and seemed to recall a somewhat experimental server feature from several years ago. Surely there must be a way to do this with Drupal now, right? Yes, indeed, drush runserver does the trick, and what’s more, drush core-quick-drupal will even handle the download and installation for you.

Reading the documentation, I took note of this in the drush runserver description:

Runs PHP’s built-in http server for development.

Built-in http server? Hmm. php -h … Well waddya know?

Usage: php [options] [-f] <file> [--] [args...]
	 php [options] -r <code> [--] [args...]
	 php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
	 php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
	 php [options] -S <addr>:<port> [-t docroot]
	 php [options] -- [args...]
	 php [options] -a


	-S <addr>:<port> Run with built-in web server.

And here I am running a whole virtual machine for this.

So, short story long, I ditched my homemade development environment and haven’t even installed VirtualBox on the new computer yet. It’s tempting to look for your own way to solve a problem and end up way over-engineering the solution. Don’t forget to take a step back now and then to see if there might be an easier way of doing things.

This reminder is more for me than it is for you.

2nd Sourdough Anniversary

Today marks what I’ve taken to calling my Sourdough anniversary: the anniversary of the day that my father-in-law and I arrived in Whitehorse with a packed U-Haul truck. The start of an exciting new phase in life for my family.

I had intentions of writing regularly about Yukon life and all of the exciting things that we were experiencing, but we are two years into this adventure and I have done a terrible job of that.

That ends now, though. Over the next few weeks, I’m going to write some brief posts that recap our first two years living in the Yukon. It may be a little late to capture anyone’s interest at this point, but it should be a good experience for me to reflect on what this change has meant for me and my family.

After that I’ll try to do a better job of keeping up with things so that there isn’t another multi-year gap in my posts.