There are some exceptional tools that can be used for WordPress development that make the process way easier than it would be otherwise. I didn’t know about some of these early on in my WordPress development days, so for those of you who might not be familiar with them, I’d like to share.
Local by Flywheel
Local by Flywheel (Mac, Windows) creates local WordPress environments with a few simple clicks, and they come up chock full of handy features to expedite development.
Creating a new local WordPress site is as simple as entering the name:
Selecting some environment options:
And deciding whether or not it’s going to be multisite:
Local by Flywheel will spin for a moment or two and soon you’ll have a brand-new local install of WordPress.
Once your site is up and running, Local by Flywheel provides a lot of neat helper tools. You can access your database via the installed-and-ready browser tool Adminer, or use the open-source Sequel Pro client. Either way, there’s no messy connection setup; just click the buttons and your in:
Email is automatically configured using MailHog, which further simplifies the testing/development process:
Local by Flywheel also supports add-ons, which brings us to our next must-have tool: PHPStorm.
There are editors and there are IDEs. PHPStorm (Mac, Windows, Linux) is the latter and it has tons of features (many that I’ve yet to use!) The reason that I find it indispensable for WordPress plugin development is, in part, because of the integration with Local by Flywheel.
One of Local by Flywheel’s add-ons is “Xdebug + PHPStorm” which needs to be enabled in your installation before these next tricks will work:
Once enabled, you can go to an individual Local by Flywheel site and click the “Configure PHPStorm…” button:
It will look almost like nothing happened until you go to PHPStorm and start a new project. You want to select “Create a New Project from Existing Files”:
Choose “Source files are in a local directory, no Web server is yet configured.”:
Finally, you will want to navigate to the correct directory for your Local by Flywheel installation. By default (on Mac) this is a folder called “Local Sites,” but I changed my to just “Sites” because I spend a lot of time on the command line and I don’t like spaces in my folder names!
The most important thing to note is that when you find your site’s files, you want to navigate into app/public and use that as your project folder:
Click “Finish” and PHPStorm will open.
There’s so much detail about PHPStorm that I’m not planning to touch here; the main thing I want you to see is this:
Notice how, in the upper-right hand corner of your screen, you have a PHPStorm run profile already defined: “Local by Flywheel”. This means that you can click the green “bug” icon and initiate the debugger. (Local by Flywheel needs to be running, and your site should be running from Local by Flywheel first.)
You can set debugging break points just by clicking in the gutter:
This gives you the ability to pause your running plugin code, examine values, and step through/into code blocks.
Using Local by Flywheel and PHPStorm together can save a developer untold hours, and as you can see, the setup couldn’t be simpler.