Before we get started, I want to apologize for how late this post has come (My talk was on October 1).
Fact: Starting a project sucks
Kind of. Getting that contract signed and seeing that deposit clear the bank is an amazing feeling. What’s next? Getting the client site setup on your computer. That’s the part that sucks. Let’s think about how most of us started with development environments. XAMPP and MAMP are a great start, but it takes up a good amount of time to setup a new WordPress site. How long does it take you to complete the following steps?
- Create the database
- Configure virtual hosts
- Install WordPress
- Edit wp-config.php
- Add dev. url to your hosts file
- Install your themes
- and plugins
- Then activate your theme
- and plugins
- Configure WordPress
- and themes
- and plugins
Now think about how many times you do this every month for each new client. Also, what’s the result? You have a development environment that might work, doesn’t match production and you’ve wasted 1-2 hours (or more) of time you could be developing. There are a couple of mediocre to bad alternatives such as using Parallels or VirtualBox (can match production), using the same install for all projects (messy), switching the database (just don’t).
There’s a much better way.
Vagrant is a tool that enables you to create new virtual machines set to your specifications from the command line. It can make your onboarding process dead simple and will burn that pesky 5 lbs. so you can hit your goal weight (I may have made that last one up). To get started, you’ll first need to install VirtualBox and Vagrant.
Let’s see how simple it is to get started.
Yeah. That’s it. Now all you have to do is install your web stack and your good to go. But wait a minute. Aren’t we web developers and not system administrators? Should we not be focused on what makes us the most productive? Crazy thought here: Developers should develop. Yeah, mind blowing.
Introducing Varying Vagrant Vagrants
Varying Vagrant Vagrants (VVV or V-Trip, for short) is a WordPress-focused Vagrant configuration that closely matches some common environments used by some of the major managed WP hosting companies. This replaces your XAMPP or MAMP install (good riddance). And unlike using Parallels or vanilla VirtualBox, you can use your local development software without the hassle of mounting the virtual disks or some other funky setup. Lastly, VVV comes packaged with some great tools such as PHPUnit, wp-cli and Grunt to make your life easier. Here’s a list of everything you get.
It’s very easy to get started with VVV. Just run the following in your terminal.
After 15-20 minutes (depending on your connection) you’ll have a fully functioning WordPress installation with the latest stable, trunk and develop branches.
But wait! There’s more!
Let’s say you create a new site for a client each month. Even with VVV you must still take 30 minutes or an hour to configure the theme and plugins. With wp-cli you can extend the startup script to install/activate your favorite starter theme and plugins, you can even import test content if you want to get really clever. Here’s the gist (ha!) of the various things you can do:
Vagrant can really shine with teams as you can export a fully-configured box and share it with your team members.
A word on my process
I tend to create a new VVV box for each client. While it does take up more disk space, at this point it’s much faster to do this than to create new virtual hosts on an existing VVV box.
I also use SASS/Compass, Grunt, and other tools installed on my local machine so I know that they will work on every box that I create.
With the latest version of Vagrant, the provisioning script required for VVV will no longer run by default. You can always type
vagrant up --provision but you can go ahead and create an alias for that command in .bash_profile:
alias vup="vagrant up --provision"
If you have any questions about Vagrant, VVV or my process please feel free to ask me in the comments!