I primarily work on the WordPress plugin Event Espresso for my living, and thought I’d share my development setup: what tools I use to make software. I do this to share the tools I’ve found handy, but also inviting feedback on how it could be improved.
- I use Windows 7 would you believe it, still, because the free upgrade to Windows 10 didn’t really entice me with anything
- I have a virtual machine (VM) that’s running Linux Ubuntu (which is nice because this Linux virtual machine is a similar setup to many web servers)
- that VM is setup to keep folders in-sync with my host machine, Windows. So I can see and edit the files locally and then the files on the VM get updated
- that VM has multiple WordPress sites on different domain names that only I can access, each one running a different version of PHP
- I have PHPStorm setup on my machine for code editing. This helps me find PHP classes and know what functions they have, avoid syntax errors, and helps me keep my code cleaner than I would in a regular editor like NotePad++
- The VM has phpunit installed so I can write and run unit tests for WordPress and plugins. These automated tests are not only handy for verifying code works, but I especially like how they help me know when I (or sometimes, someone else!) breaks the existing code
- The VM has xdebug which I setup with PHPStorm, so I can mark a breakpoint in the code, which allows me to inspect the variables and watch exactly how the code gets executed, even during unit tests
- The VM has xdebug and webgrind on it, which helps me profile the code and find the bottlenecks (I’ve found that identifying the bottlenecks and fixing them works SO MUCH better for speeding up the software than just trying to optimize everything, because the bottlenecks sometimes make the code run several times slower, whereas the small optimization’s here-and-there only speed it up by a 1%)
- I also have a PHP PSR code sniffer (used when working on Event Espresso code), and a WordPress code sniffer (used when working on WordPress core code or other plugins), integrated with PHPStorm which helps me know when my code doesn’t meet the project’s standards
- I set up my WordPress installs to be git repos, which allows me to switch branches with ease (eg switch to WordPress 4.2 and then back to the latest Beta)
- I actually just use Git Bash for running Git commands, not any fancy-er GUI like GitKraken or SmartGit. I’ve used those but so far prefer using the command line directly. The command line allows me to easily use git blame and git bisect (which, last I checked, I couldn’t figure out how to do with SmartGit, although I bet they support it somewhere). What’s more most of the documentation I find always refers to the command line, so in that way it’s a bit easier. Also, if there’s an error, I know it’s an error with Git, I don’t have to wonder if it’s a problem with my GUI.
- My host Windows machine has a small program called “Dexpot” on it, which gives Windows multiple desktops like on Mac and Linux. This way, I set up PHPStorm in the first desktop, a web browser (usually Firefox) in my second desktop, a bunch of terminal windows (actually, Git Bash windows usually, which have a lot of Linux-type commands but on Windows), and a database program (HeidiSQL, in my case; just because it’s pretty lightweight, does what I need, and doesn’t require installing the entire .NET framework like others do). I set up Dexpot so all I need to do is press F1 to go to the first desktop, F2 to go to the second, etc. I have a second monitor but really don’t use it much because having multiple desktops meets my needs
Setting up each of those tools could be a tutorial unto itself. Actually, there are tutorials and resources for each.
Here’s the resources I’d recommend for setting those up:
- Go to the vvv page for instructions on how to set a VM that’s ready-to-go for WordPress development, handling multiple versions of PHP simultaneously and xdebug (heads-up: you’ll need to setup virtual box, or another program for running VMs, and vagrant, a program for setting up standardized VMs like vvv)
- Read this detailed blog post on how to setup PHPStorm with xdebug
- Here’s some instructions on setting up PHPStorm with a code sniffer
- Ability to access the VM from a different machine (like my phone) from the network
- More speed! On VVV 2.1, a WordPress website with no plugins active usually takes 2 seconds to load a page; but once I load up a ton of plugins on it the requests take 5-10 seconds
My favourite tools are having an IDE to help me figure out where PHP classes are and how to use them, code sniffers to help me format the code correctly, and xdebug integrated with my IDE so I can step through the code.
I hope this gives you some ideas on how to improve your programming setup. While it’s a pain to set things up, I think each of these tools helps me be a better programmer.
Questions? Is your setup better? Tweet me or comment!