WordPress plugin in PhpStorm 10

I needed to create a new plugin for WordPress, so I decided to take advantage of the JetBrains Toolbox license I have and use a PHP IDE called PhpStorm. The support for WordPress is supposed to be great, with coding assistance specific to WordPress. Setting things up took a bit of figuring out so I’m going to document the steps.

Note: This might not be any different than it was in PhpStorm 8 or 9.

In my examples I’m using MAMP as my Web Server and PHP.

  1. First we start PhpStorm and click “Create New Project”

phpstorm-10-0-3-title

  1. Next, we give the plugin a name and enter the WordPress installation path. Click “Create”.

wp-plugin-wizard-page-1

  1. We are presented with the main IDE of PhpStorm.

phpstorm-created-wp-plugin

  1. In the status section (click the bottom-right corner to bring it up if it’s not up), click the links to enable WordPress code style and WordPress installation.

phpstorm-php-mamp

  1. If no Interpreters are listed here then you may need to add the reference to one by clicking the ellipsis button next to the dropdown and summoning the dialog box shown below. The screenshot shows an example of a path to the PHP that comes with MAMP.

phpstorm-php-interpreters

  1. In Preferences | Build, Execution, Deployment | Deployment, add a “web server” by clicking the + sign. Enter a name and specify its type as “local or mounted folder” so that PhpStorm can upload files into the plugin folder easily.

phpstorm-deployment-1

  1. Now, in the “Connection” tab, specify the WordPress folder as the “Upload/Download project files” folder (this is the directory that PhpStorm will treat as the project root when deploying). Specify the Web server root URL if you have your web server accessible at some URL. In the case of MAMP it would be http://localhost:8888.

phpstorm-deployment-2

  1. Next, in the “Mappings” tab, enter for Deployment path on server the value of “wp-content/plugins/<project-name>”. This means that when you choose to “deploy” this project, its files will be placed in this folder. After all, we are creating a WordPress plugin. Click “OK”.

phpstorm-deployment-3

  1. Back in the main IDE, there should now be an “Upload to <web server name>” item in the Tools | Deployment menu. Click it, and this should “upload” the files to the plugin directory of your local WordPress installation.

phpstorm-deployment-4

  1. Now enter the WordPress Admin and go to Plugins. Now you see the plugin here!

wpadmin-plugin-added

Yay!

  • Rustem Zakiev

    Ok. But how to debug plugin. After every code editing I need to deploy files to local WordPress folder? Is there a way for realtime development?