Theme Juice: A New Auto Site Generator for WordPress Development with Vagrant

photo credit: Roma
photo credit: Roma

As WordPress developers everywhere are adopting Vagrant for local development, new configurations seem to pop up every week to address the needs of different teams and workflows. Theme Juice is the newest open source project to join the ever-growing list of WordPress-related Vagrant resources.

The project is based on VVV, one of the most popular and best-supported Vagrant configurations. Its VM is built on an Apache fork of VVV called VVV-Apache.

Theme Juice installs as a Ruby gem and requires requires Vagrant and VirtualBox. The tj create command leads you through prompts to set up project information, location, database info and will then create a local development environment (if one isn’t already in place.) It automatically syncs the local project location with the project location within the VM, enabling it to be run from anywhere on your system. (2)

It also supports Windows with a few feature limitations.

If you are not using Apache, Theme Juice can be modified for use with Nginx via the original VVV, which is as easy as running it with a few flags:

tj new --vm-box --nginx

Access Projects from Other Devices, Including Mobile

One of the unique features of Theme Juice is that every project created with tj is automatically set to support, a free magic domain name that provides wildcard DNS for any IP address. This enables access to virtual hosts on your development server from other devices on your local network, ie. tablets and phones. This works best with OSX, according to TJ’s documentation:

If you’re using OSX, then everything should work out of the box. If you’re not using OSX, then you’ll need to point port 80 on your host machine to 8080; Vagrant cannot do this by default for security reasons.

Once everything is good to go, you can access a project from another device on the same network by going to:
< project-name >.< your-hosts-ip-address >


This feature allows you to easily test your development projects on mobile devices with no extra configuration required.

The Origins of Theme Juice

The project was created by Ezekiel Gabrielse and the folks at Produce Results for internal use at their agency. Gabrielse is the lead developer for a small team of developers for whom Theme Juice is now an indispensable tool.

“We work at a fast pace, so having the ability to create and remove development projects easily, a well as quickly restore/set up existing projects, is essential to keeping our flow, well, flowing,” he said. “We’ve been dogfooding and developing this utility for almost 10 months and are excited to finally get it out to the community.”

Gabrielse built Theme Juice to ease the process of creating new development sites, which he found to be somewhat inconvenient with VVV.

“After a few weeks of using vanilla VVV, I quickly realized that the process of creating a new site was very repetitive, and like any developer, I sought to automate that repetition,” he said. (This was long before Variable VVV was released, which automates site creation and deletion.)

“What started as a quick little (actually, it got pretty large) Rake task included in our company starter theme, quickly grew into a separate project that I extracted out to a Ruby gem.”

The resulting Theme Juice project integrates with VVV and leverages many of its unique features but adds auto site setup and additional functionality to manage build tools for Gabrielse’s development team.

“Suffice it to say, it saves us time by automating the entire process of creating new development projects,” he said. “We also incorporated a sort of crude scripting via a configuration file (called a Juicefile) that allows us to easily run any build processes we need to upon project creation.”

Once Gabrielse realized how useful that functionality was, he pushed it out further and abstracted all of the team’s build tools to the configuration. This enabled them to seamlessly switch between tools whenever a project required it.

“We’ve recently changed from Guard to Grunt, from NPM packages to Bower packages,” Gabrielse said. “Having all of those tools abstracted out to tj commands, we didn’t have to change anything in our workflow, our build scripts, our deployments, etc., because everything was already using the command aliases provided by tj. This also allows us to transition from project to project without having to worry about how to run the build tools for that particular project, as it’s all abstracted out, so that we can focus on the task at hand.”

Theme Juice caters towards experienced developers who like to use modern build tools and systems for their development.

“Using our starter theme, we use Composer for PHP/WP plugin management, Bower for front-end dependencies, Grunt for managing build tools, which includes Coffee, Haml, and Sass compilation,” Gabrielse said. “At first glance this seems daunting to have to manage all of that, but with using tj, it’s easy.”

A list of all the global options and commands is available on the Theme Juice documentation page.

In the future, Gabrielse plans to extend Theme Juice to handle deployments. Right now he is leaning towards integrating an automated Capistrano workflow but is open to other suggestions now that the project is public. Anyone who is interested in contributing can find out more about the process on the project’s GitHub home page.


10 responses to “Theme Juice: A New Auto Site Generator for WordPress Development with Vagrant”

    • Bitnami runs on your own machine. VVV and the likes use virtual machines which don’t have a risk of corrupting your system, allow you to test against multiple server configurations, and allow for a team to have the same server configuration – hopefully reducing the “it works for me” syndrome.

      • Correct. Vagrant (and virtual machines in general) allows for rapid development. In addition to being able to easily share/distribute VMs, you can also destroy and rebuild a VM at any time, giving you complete freedom to test inside of a sandboxed environment. Vagrant also allows you to perfectly mirror your production environments (though we don’t often do this); as far as I can tell, Bitnami does not allow such freedoms.

    • Both projects were actually created around the same time (Oct/Nov last year), but ours was in private development. Variable VV is a really great project. I continued to develop ours to allow more flexibility and to make sure that it is well tested, since it’s written in Ruby. Also, a nice side effect of building it in Ruby is that it supports Windows, which as far as I know, no other site generator does (since they’re all written in Bash).

        • It really depends on you and your team. Theme Juice isn’t simply a site generator, it’s also a site manager. It helps you manage and organize your build tools, it sets you up to test on other devices via, and hypothetically, it could even manage multiple Vagrant installations e.g Nginx VVV, HHVM VVV, and Apache VVV.

          Another thing to note is that you can have your projects live anywhere on your file system, (as opposed to having them directly inside the VM’s www/ directory), since everything is shared with the VM (think: symlinks). These points alone show the flexibility of our CLI. Hopefully within the next month we’ll have deployments/migration handled as well!


Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: