Configuring JetBrains PhpStorm IDE with Drupal on Pantheon

Best practices and recommendations for building a Drupal site using JetBrains PhpStorm.


JetBrains PhpStorm is a commercial PHP IDE that you can configure to work with your Drupal sites. For detailed information, see Drupal Development Using PhpStorm and Developing on Pantheon with PhpStorm.

This article covers some best practices and recommendations for building a Drupal site on Pantheon using PhpStorm.

Initial Site Setup

After you've created your site on Pantheon, you'll need to set up your local environment.

Clone the Code Repository

Make sure your Dev environment is in Git mode, then clone your Git repository to your local workstation.

Create a New PhpStorm Project

  1. Open PhpStorm and create a new project from existing files.
  2. Choose the project directory.
  3. Select the parent folder for all the project sources and click the icon, or choose Project Root on the menu.
  4. Click Finish.

Configure a PhpStorm Project

  1. Ensure that PhpStorm uses Drupal settings by going to Preferences > Drupal.
  2. Enable Drupal integration and select the Drupal installation path.
  3. Set up PHP/Include Paths.
  4. Choose the Drupal major version.
  5. Configure the correct version of PHP by going to Preferences > PHP, and choose PHP Language Level 5.3.

Drush Support

We recommend enabling Drush support.

  1. From Preferences > Command Line Tool Support, click Plus.
  2. Choose Tool > Drush, and specify the path.

Configure On-Server Development

  1. Put your Dev environment into SFTP mode, and click Connection Info to see the connection settings.
  2. Within PhpStorm, go to Tools > Deployment > Configuration.
  3. Click plus for the add server dialog.
  4. Enter the Pantheon site name followed by a dash and the environment.
    Example: Yoursite-dev.
  5. Type SFTP and click OK.

Connection Tab

Configure the server connection tab in the following order:

  • SFTP Host: SFTP Host from Connection Info
  • Port: 2222
  • Username: Username from Connection Info
  • Auth Type: Key Pair
  • Private Key File: Navigate to the location of your id_rsa file. Example: /Users/jon/.ssh/id_rsa
  • Click Test SFTP Connection...
  • Root Path: Click Autodetect, and navigate to the end of the detected path and add /code to the end

Mappings Tab

  1. Deployment path on server: /code
  2. Web path on server: URL of your Pantheon Dev environment. Example: https://dev-yoursite.pantheonsite.io
  3. Click OK.
  4. Go to Tools > Deployment > Automatic Upload > and select the server you created.

Now any files you change and save locally will be automatically uploaded to Pantheon.