Configuring JetBrains PhpStorm IDE with Drupal on Pantheon

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

Contributors: Steve Zipfel.

Discuss in our Forum Discuss in Slack

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. From the Create New Project: Choose Your Scenario, window select Source files are in a local directory, no Web server is yet configured, then click next:

    PHPStorm new project wizard

  3. Choose the project directory.

  4. Select the parent folder for all the project sources and click the Project Root icon, or choose Project Root on the menu.

  5. Click Finish.

Configure a PhpStorm Project

  1. Ensure that PhpStorm uses Drupal settings by going to Preferences > Languages & Frameworks > PHP.

  2. Expand the Drupal dropdown.

  3. Enable Drupal integration and select the Drupal installation path.

  4. Set up PHP/Include Paths.

  5. Choose the Drupal major version.

  6. Configure the correct version of PHP by going to Preferences > Languages & Frameworks > PHP, and choose PHP Language Level 5.3.

Drush Support

We recommend enabling Drush support.

  1. From Preferences > Tools > Command Line Tool Support, click Plus.

  2. Choose Tool > Drush, and specify the path.

    Drush Support

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 Build, Execution, Deployment > Deployment.

  3. Click plus for the add server dialog, and choose SFTP

    PhpStorm on-server development settings

  4. Enter the Pantheon site name followed by a dash and the environment. For example, anita-drupal-dev.

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, then 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:

  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.