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.
- First we start PhpStorm and click “Create New Project”
- Next, we give the plugin a name and enter the WordPress installation path. Click “Create”.
- We are presented with the main IDE of PhpStorm.
- 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.
- 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.
- 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.
- 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.
- 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”.
- 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.
- Now enter the WordPress Admin and go to Plugins. Now you see the plugin here!