Plenty of posts have been written about setting up a local development environment for WordPress, but when I moved to a new Macbook (running OS X Yosemite) I couldn’t find a post that contained all the instructions I needed. After some searching I got everything up and running and thought it would be worthwhile to share my process and tools here for posterity.
I use my local development environment for:
- WordPress plugin development
- Working on WooThemes products (plugins & themes)
- WordPress core contributions
- Working on client sites
For this I use the following tools:
- Vagrant for the general development environment
- SVN for checking out WordPress trunk and managing my plugins on the WordPress.org repo
- Git for managing my public plugin repositories as well as all of the WooThemes product repositories
- Sublime Text for editing code
The initial setup of the Vagrant environment was easy using Varying Vagrant Vagrants. They have a complete step-by-step on their GitHub repo, so you shouldn’t struggle getting that up and running. It did take quite a while to set up, but that’s only because it has to download a lot of software in order to work – it’s relatively uncomplicated to get it working though.
VVV comes with some handy features for WordPress development, most notably it includes the WordPress trunk repository checked out from SVN. This enables you to get the latest development version and create patches to submit to Core Trac easily.
One thing that VVV doesn’t include by default is the ability to easily generate new WordPress sites on the fly. If you’re developing sites for clients, or if you often require new sites for testing, then this is pretty much essential. Luckily, there’s a VVV add-on script that handles this for you very easily: Variable VVV by Brad Parbs. The wizard is a single script that is super easy to use and will generate new sites for you with no additional work on your part – simply follow the simple guide in the GitHub repo and you’ll have no problems.
Additionally, Leo Gopal has created a new VVV dashboard that lets you manage your WordPress installs with greater ease – it provides a friendly UI and easy to use tools. You can grab it from GitHub.
There’s no need to install SVN before setting up VVV, but in order to use the WordPress trunk SVN repo you need to upgrade the default SVN version. If you’re not sure how to do that, then this guide will run you through the (very quick) process.
If you aren’t comfortable using SVN in the command line then I recommend using Versions to manage your SVN repos through a robust GUI.
You don’t need to install anything extra to manage your Git repos, but if you would rather not use the command line to manage things then SourceTree is your best bet for a functional GUI for managing both GitHub and Bitbucket repos.
The code editor you use is entirely based on your own preferences, but I like to use Sublime Text 3 for development. The main reason for this is the plethora of add-ons that are available for it – some of which are hugely helpful for WordPress development.
Before you can install add-ons for Sublime Text, you need to enable Package Control. Once you’ve done that you can install any of the available add-ons. These are the ones that I use:
- Alignment – Easy alignment of multiple selections and multi-line selections
- Bracket Highlighter – Bracket and tag highlighterto help you navigate your code more easily
- Gist – Allows you to create new Gists from selected text
- LESS – LESS syntax highlighting
- Sass – Sass syntax highlighting
- SCSS – SCSS syntax highlighting
- SidebarEnhancements – Adds some useful additional features to the files and folders sidebar
- SublimeLinter – Interactive code linting framework
- SublimePhpTidy – Format PHP code to meet the WordPress Coding Standards (install instructions for Sublime Text 3)
- TrailingSpaces – Highlight trailing spaces and delete them in a flash – very useful for cleaning up messy code
- WordPress Developer Resources – Easily search the new WordPress Developer Resources right from your code
- WordPress Readme to Markdown – Easily convert your plugin’s readme.txt file to markdown for use on GitHub
The colour scheme I use these days is the Material Colour Scheme – based on Google’s Material Design UI. It provides a dark background with bright colours – kind of like the popular Monokai, but brighter.
That’s my setup – what do you use?
Hey Hugh, great post.
Always wondered if moving to vagrant (from MAMP) is worth it.
This post was quite easy to follow through, do you ever use WP-CLI?
Also – You are using sublime, I am using Coda 2.5 and sometimes Atom – mostly for the wordpress/php auto-complete which makes things so much faster when developing, does sublime have similar?
Eternal Smiles, Leo Gopal
I was using MAMP on my previous laptop and, after having made the switch, I find Vagrant to be better in three main ways: It’s easier to setup (using VVV), more flexible and less bloated. It’s also easier to keep up to date with Vagrant, whereas I found MAMP more difficult in that regard.
I’ve never used WP-CLI, so can’t comment on that side of things.
Sublime Text has built-in auto-complete for PHP and WordPress core functions, so you’re good to go on that front. I’ve never tried Coda, but Atom seemed to be pretty solid when I first tested it out.
oh awesome, I didnt know about the auto-complete being default in Sublime – Now even more reason to try it out again (busy installing the packages you mentioned, they are sweet!)
Thanks for the tips.
great overview! I use VVV as well and like Vagrant for some months now. I also used MAMP previously and switched completely.
@Leo: VVV has WP-CLI installed. You can ssh on your vagrant and just use wp-cli without any configuration. Great tip 😉
@Hugh: You mentioned the “VVV Site Wizard” script. I used it couple of times and it definitely works. But do you use one vagrant (VVV) for all your projects (dev, clients, etc.) or do you have multiple vagrants for different projects?
I currently use one vagrant instance for all my projects, but I’ve only recently started using it and depending how many projects I end up having I might start using multiple instances.
@Hans-Helge, great tip! Definitely going to get VVV installed now – been playing with WP-CLI lately and its definitely worth the move.
Been using Vagrant ever since you posted this article, loving it Hugh.
I also made a switch to Variable VVV, A Site Creation Wizard. Its a bit more robust with more features (and active development).
I also created a VVV-Dashboard you may like, take a look, let me know what you think.
VVV-Dashboard -> https://github.com/leogopal/VVV-Dashboard
I’m going to be trying out Variable VVV soon – it’s a fork of Alison Barrett’s wizard that I mentioned in this post, so it should be an easy move to make.
Your dashboard looks really cool – nice work! I’ll test it out this week 🙂
Had a look at your VVV dashboard last night and it’s really cool – easy to install and is a huge improvement on the default one. Really awesome work man!
I’ll update the post to mention it 🙂
Thanks for the mention Hugh, appreciate it!
If you have any suggestions for improvements, hit me up. I just released an UI update making the feel a lot cleaner.
Also, Variable VV is seamless (just one ‘v’ less when working with it) and you may love the Blueprint feature, mine auto installs WooCommerce with Storefront if I choose my ‘woo’ blueprint.
I like to use Codelobster. It has special plug-in for WordPress development: http://www.codelobster.com/wordpress.html
Any recommendations for Ubuntu/Linux.
Has anyone used Local by Flywheel, looks like they don’t have Linux version though.
I have since moved to Linux (Kubuntu) and I continue to use VVV – it is built for Linux as well. I listed a few options in this thread here as well: https://twitter.com/hlashbrooke/status/912631824077205504
Thank you, I am going to have to try that to streamline development of WP projects that I work on.