I was looking for a new project today and decided to revamp my WordPress development environment to use Varying Vagrant Vagrants. It’s a great project with an even better community around it. If you’re doing any kind of WordPress development, I highly suggest you take a look and see if it can work for you.

VVV Shared Folders

One of the difficulties I had in getting started was how to keep my plugin repositories in their current location, while still giving the virtual machine access to the files. I found a great article from Sudar that covered how to get directories synced to the virtual machine using Vagrant’s synced_folder capability. This setup worked great for my complete plugins, unfortunately it wasn’t going to be a solution for single file plugins.

Shell Provisioner to the Rescue

I have a couple of simple mu-plugins that don’t have complete plugin directories. Instead they rely on single php files in the mu-plugins directory to execute their functionality. As the name synced_folder implies, it’s only for folders. So after syncing my folders I needed a way to execute shell commands for creating symlinks to those files.

My solution was to use Vagrant’s shell provisioner coupled with synced folders to sync individual files. I tossed all of this in my Customfile and magic started happening!


How it works.

  1. First we sync the folder from it’s development location on our computer, to a path already being mounted by the vm. You could also choose to mount an additional path (which I may do at a later point).
  2. This is the command we’d run from shell to create the symlink from our new synced folder to the site on our system that needs the plugin file. In my case I’m syncing a specific php file to the mu-plugins folder on the site I use for testing.
  3. Finally, we execute the shell script.

Now that this is configured, I can easily work on my plugins in their development directories and instantly have those changes synced to the vm for testing. No need to copy files, or worry about editing the wrong files.

I’d love to hear your feedback on this method, or if you have an even better method for making this happen, LET ME KNOW!