The Ultimate WordPress Development Environment
WordPress development has come a very long way in recent years when it comes to tooling. In the past, developing a WordPress website required some sort of MAMP/WAMP localhost setup and almost always, a rather painful headache. Maybe you’re even one of those developers who developed their website on a live environment – I was.
Luckily, times have changed and there are now tools that help take the headache and repetitiveness out of building WordPress sites on your computer.
In December last year, after 3 years of being almost completely devoid of any WordPress development, I became a full time WordPress developer again. Before that 3 year stint in the payments industry, I was a full time WordPress contractor.
Being out of an industry for 3 years, gave me a unique perspective on how fast things change in computing and more specifically, web development. WordPress development is no exception.
You see, when I returned to WordPress development in December last year, I decided to look at setting up the perfect WordPress development environment. I was pleasantly surprised to see that the tooling around WordPress had advanced so much that it was much like trading in a Ford for a Ferrari.
I was excited, and still am of course, to explore all the tools and in today’s article I’m going to share with you a summary of what I have learned. Hopefully it will help you tweak your current environment and implement some of the tools that are available to you.
It Starts with the Server
To begin with, the most important piece in the WordPress development environment puzzle is the server. Without a server, we can’t do anything.
There are so many different options available today to host WordPress websites on your local environment that it gets tricky to know which one to use.
I’m going to suggest that you drop MAMP/WAMP/XAMP and start using a virtualized development environment.
Why? There are so many reasons:
- It’s an isolated environment. By using a virtualized environment you’re creating a development server that is isolated from your host operating system. You can install whatever operating system you like on the virtual machine and start/stop/restart it without affecting your host. It’s easy to tear down once you’re done with development and no longer need it.
- Messed something up? No problem! Just rebuild the environment. I’m sure we’ve all been in the sticky situation where we’ve tinkered with our server settings and blew stuff up. This is easily fixed by rebuilding the virtual environment or simply using snapshots. So now you can play around and tweak your settings without fear of failure.
- As close to live as you can get. You can literally replicate your live environment on your localhost if you wanted. Having these two environments exactly the same helps with debugging, tweaking and even deployment.
- You can run multiple different server environments, on a single computer. Have one client using Apache and another Nginx? No problem, create those two different environments in virtual machines and you’re good to go.
- Unified environment across development teams. If everyone on a development team uses the exact same setup, it speeds up development time and there are less questions about why something is not working on x person’s machine.
Now that you’re sold on a virtualized environment. What should you use?
I’m using VVV. For me it was extremely straight-forward to get up and running, has a good support system around and it is used by many of the big WordPress development agencies, including the one I work for, XWP.
Some of the other options for a virtualized WordPress development environment include: HGV, Wocker, VIP Quickstart.
If you decide to go with VVV, then I definitely recommend the following plugins and tools to take VVV to the next level of awesome.
- vagrant-hostsupdater – This plugin allows your vagrant installation to update the entries in your computer’s hosts file for adding domain mappings to an IP address. This means you don’t have to manually add entries to your hosts file.
- Variable VVV – By far the most useful tool for VVV is called Variable VVV and what it does is gives you the ability to quickly and easily create new VVV WordPress installations using the command line. Definitely check this one out
Aleksander Koko has previously written about VVV, and I’ve also recently recorded a video on how to setup VVV on your own computer.
The Power of the Command Line
Who doesn’t like a bit of command line fu, right? WP-CLI is the answer to your inner command line desire.
WP-CLI let’s you manage a WordPress installation from the command line (it ships with VVV by the way).
Let’s look at some practical examples of how you can use WP-CLI in your local development environment.
- Install WordPress. SSH’d into your server and need to install WordPress quickly? Simply use WP-CLI to create a new WordPress installation.
- Update WordPress. There’s not much more painful than updating tons of WordPress websites by visiting each one, logging in, clicking around and then updating. You can do this straight from the command line with a single command.
- Installing plugins. If you’ve found a great plugin that you want to install across multiple sites, again, do it with one command using WP-CLI.
- Resetting a WordPress database. Messed something up and want to start off fresh? Easy, one command (this is getting a little repetitive isn’t it?)
- Import content. Yep you guessed it, you can import content into your WordPress install or multiple installs with one command.
- And so much more
That’s all quite handy stuff that you can do from the command line. Best yet, in the next section we’ll talk about an IDE and you can run all these commands directly from that IDE.
If you’re interested in learning more, check out this article on WP-CLI by Ahsan Parwez.
An IDE That Makes a Difference
Out of all the tools I am talking about today, I have a feeling that this is going to be the most contentious. When it comes to IDEs and editors it’s almost as if you’re invading personal space, and a lot of people don’t like that.
I’m not going to try and tell you an IDE is better than a text editor or vice versa. What I’m going to do is tell you my experience of switching to an IDE and how it worked for me.
I have always been someone who has disliked IDEs. Dislike is probably being kind, I hated them. I felt they were bloated, slow and cluttered.
I was a big Sublime Text fan (and still am by the way, I use it daily).
So in December, as I was getting back into WordPress development, I checked out what editors were available to write WordPress code. I was quite surprised when an IDE by the name of PhpStorm kept getting a mention.
Reluctantly, I took a look and boy am I glad that I did!
PhpStorm is the best IDE for PHP and WordPress development, in my opinion. It offers everything you need to build WordPress websites, plugins and themes all in one place and it has incredible WordPress integration (you really need to check it out).
Here are three reasons why you should consider PhpStorm this year for WordPress development:
- Everything you need, in one place. FTP – check, database support – check, terminal – check, version control – check, debugging – check, refactoring – check, great intellisense and autocomplete – double check! And so much more.
- WordPress integration within PhpStorm is second to none. PhpStorm understands WordPress deeply. Once it’s hooked up to a WordPress project it knows how everything ties together. It autocompletes on WordPress functions and even on actions and filters.
- Many of the top WordPress developers and agencies are now developing their code with PhpStorm. That to me is a clear sign that it’s one of the best IDEs for WordPress development available.
If you’re interested in getting started with PhpStorm, then check out a series of 7 PhpStorm videos that I recorded to get your started with the IDE.
Making Sure Your Code Is Silky Clean
The last tool that I am going to write about today is a doozy! I’m particularly pedantic when it comes to writing code. I like it to be silky clean and follow the WordPress coding standards to a tee.
But even being that pedantic, we’re all humans. And very often I find myself going through the code that I have written and cringing about a missed space or extra new line.
Being in the Open Source world, it’s extremely important that developers stick to coding standards that are defined by the projects otherwise a codebase degrades extremely quickly, especially on a popular Open Source project like WordPress.
In fact, the WordPress core team is particularly strict about coding standards and that they’re followed.
So how can we make sure that our code follows the WordPress coding standards? The answer is simple and it is a tool called PHP CodeSniffer with the WordPress coding standards ruleset.
These two utilities will scan your code, find any discrepancies between your code and how it is expected to be written by the WordPress project and inform you of what is wrong. Magic!
Best of all, they will also notify you of any high level security issues that it encounters. Now it won’t catch every single security issue so make sure you’re always thinking about security when you’re writing your code but it is a good first line of defense.
Of course, I wouldn’t be able to complete this section without mentioning that PhpStorm has baked in support for PHP CodeSniffer. I’ve released a video on how to tie PhpStorm, PHPCS and the WordPress coding standards ruleset together.
There are many alternatives to the tools above and my hope is that at the very least everything I have spoken about today gets you interested in exploring some of the awesome tooling around WordPress development.
The above tools, should you chose to use them, will give you a great foundation for getting started with a more streamlined and automated approached to WordPress development.
If you have other tools that you use, I would love to hear about them in the comments below!