Pick our brains...

Using VV to Quickly Scaffold New Local Sites

Why Use a Scaffolding Script

I mentioned in the post on installing VVV that there are tools that are useful for scaffolding new, local sites. To summarize the steps involved in doing this by hand, you would need to:

  1. Create a folder inside www to hold the files for the new site
  2. Edit the nginx configuration inside VVV to point to these files
  3. With VVV running:
    • Create the MySQL database
    • Install WordPress
    • Install any plugins or themes that are to be used
    • Import existing or dummy content

Not a lot to do, but using a tool to automate things is helpful and less error prone. Out of the box, VVV has a good system for rolling your own site scaffolding scripts. See the Auto Site Setup section of the VVV wiki.

However, part of the beauty of open source things, is that someone has already experienced this pain point, and has tried to address it. See Examples of VVV auto site setups for more inspiration on how you can make your own setup scripts, or how to use and improve an existing solution.

Using VV

My personal favorite from that list is vv by bradp. VV stands for Variable VVV and is a powerful shell script used to automate the above tedious tasks of creating a new WordPress site.

Using a terminal, I can quickly scaffold out a new local site by executing:

vv create --domain theme-testing.dev --name theme-testing --sample-content

and answering a few additional questions like “Should this be a multisite install?” or “Is there a GIT repo to be used for the wp-content folder?”.

Using the above command as an example, VV will take the script arguments and the answers you provide to:

  1. Halt VVV if it is running
  2. Create Nginx entries so the server responds to theme-testing.dev
  3. Create a folder for files which is located at www/theme-testing
  4. Create a scaffolding script called vvv-init.sh which does things like create the MySQL database, and download the specified version of WordPress. Specifically with the above command, --sample-content will download and import a number of posts and comments that can help identify edge cases of content in your WordPress themes.
  5. Re-provision VVV by executing vagrant up --provision. Part of this process involves actually executing the above vvv-init.sh script

Depending on when you last provisioned VVV, this last step might take a while as various pieces of VVV, such as node, or WordPress Core are updated for the default sites.

Once provisioning is done and if you used the above example, you should be able to access your new site at theme-testing.dev, complete with multiple taxonomies and edge-case posts designed to break your theme!

Installing VV

VV is just a simple bash script, so installation is as simple as adding the script to your $PATH.

For me (on Linux), I have vv included in my dotfile’s bin folder.

Installing for a Mac is simple and covered in the installation section of the Repo’s readme.

For Windows users it depends on how your terminal is setup.