JetBrains PhpStorm is a commercial PHP IDE that can be configured to work with WordPress sites, allowing users to easily build and maintain custom plugins. This doc will set you up with a local environment in PhpStorm to create your custom plugins and themes.
For detailed information, see WordPress Development using PhpStorm. This document focuses on integrating and showcasing the PhpStorm workflow and is current as of PhpStorm version 2017.1.4.
Create a WordPress site
If you do not already have one, create a new WordPress site on Pantheon. This will be your empty site, in which to develop your new plugin or theme.
Clone the Code Repository
Create a PhpStorm Project
Click Create New Project from the startup window or go to File Menu > New Project... if you have an existing project open.
Name your project.
Select WordPress Plugin as the project type on the left sidebar.
Specify or browse to the file path to save your project's files. This is where PhpStorm will store its "working files", and should be separate from your WordPress directory.
Specify or browse to the root directory for your local WordPress site, and click Create:
There will not be any files open within your project once you complete these steps. You will find a PHP file in the project's root, which contains the standard plugin header for WordPress.
Configure WP-CLI (Optional)
Many WordPress plugin developers use the command line tool WP-CLI. This is useful if you have a local development environment and want to use WP-CLI to manage it.
NoteYou must successfully create a project before adding WP-CLI as a Command Line Tool.
Once you have installed WP-CLI on your local machine you can configure PhpStorm to recognize WP-CLI from within your project by following these steps:
- Launch PhpStorm Menu > Preferences...
- In the Tools Section click Command Line Tool Support then click the click + icon to add an entry.
- Choose the tool WP-CLI, and click OK.
- Select Executable Available and enter the file path to your local
- Click OK to save the changes.
Configure Your Pantheon Development Environment
- Put your Dev environment into SFTP mode, and click Connection Info to see the connection settings.
- With your PhpStorm project opened, go to the Tools Menu > Deployment and click the Configuration... option.
- Click + to add a web server.
- Enter your Pantheon site name, followed by a dash and the environment.
- Select SFTP for type and click OK.
Use your site's SFTP connection information to configure the Connection tab:
Auth Type: Select Password and specify password, or key pair and select your private SSH key.
Root Path: Click the Autodetect button and the Root Path should be automatically populated:
Click the Test SFTP Connection... button and make sure the connection is successful before moving forward. Click OK.
Provide the file paths within the Mappings tab to allow correspondence between project folders:
- Local path: This field is automatically populated and requires no edits.
- Deployment path on server:
- Web path on server:
- Click OK.
Enabling Automatic Upload
Go to Tools Menu > Deployment > Automatic Upload.
You are now ready to begin editing your code. Any files you change and save locally will be automatically uploaded to your Pantheon development environment.