PhpStorm is the best PHP IDE available and you should use it. If you don’t agree stop reading. Did you stop reading? No? Good, then you aren’t a dumbass let’s get started.

This tutorial explains how to setup PhpStorm to work on WordPress Plugins (and Themes).

Target audience: Intermediate to advanced.

UPDATE (2014-03-21): PhpStorm 8 (and up) supports WordPress development out of the box. Check it out!

This tutorial will not show you how to use PhpStorm. I assume you are already using PhpStorm or want to learn and will do so on your own. This tutorial will not show you how to develop for WordPress. Yes, WP sucks and is ass-backwards PHP. Or yes, WP is amazing and powers ~20% of the web. For whatever reasons, you are here for this info.

Benefits of this type setup:

Automatic code completion, code navigation, PhpStorm’s kitchen sink.

Ability to mix version control systems (Git, SVN, Perforce, CVS, …) and sources (GitHub, SourceForge, Codebase, core.svn.wordpress.org, … )

(Git, SVN, Perforce, CVS, …) (GitHub, SourceForge, Codebase, core.svn.wordpress.org, … ) Work on multiple plugins (and themes) at the same time for the same project.

I’m a developer at PressBooks.com. This is my project setup:

This structure makes up the bulk of PressBooks dot com, that is:

WordPress 3.5.x (Subversion)



PressBooks (GitHub)

The front page of PressBooks dot com (a private theme, hosted at Codebase)

Internal stats dashboard (a private plugin, hosted at Codebase)

Prerequisites

LAMP on localhost or LAMP on VM with mapped folders. (If this doesn’t mean anything to you then stop reading and come back when it does, young padawan)

PhpStorm -> Quick Start -> Open Directory

PhpStorm -> File -> Settings

Directories

Under Project Settings, select Directories. Add each content root that makes up your WordPress project.

Deployment

Under Project Settings, select Deployment. Click the green +. Create a deployment profile of type “Local or Mounted Folder”. I named mine: TextoPress. Rename accordingly. Remember this renaming for the Install section that will come later. Select the Connection tab. Change “Folder” to: the root path of your WordPress site. Change “Web server root URL” to: the root URL of your WordPress site.

Select the Mappings tab.

Map WordPress to: /

Map Plugins to: wp-content/plugins/__PLUGIN_NAME__

Map Themes to : wp-content/themes/__THEME_NAME__

Replace __PLUGIN_NAME__ and __THEME_NAME__ accordingly. Click on the above screenshot and squint for more details.

Under Project Settings, select Deployment -> Options. Change “Upload changed files automatically to the default server” to: Always. Change “Upload external changes” to: true.

Version Control

Under Project Settings, select Version Control. Add your VCS repositories.

Install

Apply changes. Right click on your project. Select “Upload to TextoPress” (Don’t see TextoPress? Exactly. Re-read the Deployment section above…) Navigate to your web server root URL. Install WordPress using the Famous 5-Minute Install. Eventually:

Remember:

You are editing a copy of the code, not the deployed code. If something seems weird always start by doing “Upload to TextoPress ” which from here on in will be known as “Did you plug it in?”

TextoPress You can add and remove plugins (and themes) as you feel like. Rinse and repeat the instructions above until you get the hang of it.

Code is poetry. Bad, wince-worthy poetry.