Académique Documents
Professionnel Documents
Culture Documents
Tweet
Getting Started
For this tutorial, we'll assume a site has already been created on Pantheon. A tutorial is available in the Pantheon docs explaining how to create a
site.
Pantheon provides two ways of working with the platform. We can connect using Git, develop locally and push changes to Pantheon once we
want them to go live. The other way of working is using SFTP where we deploy our changes on the Pantheon servers directly, either manually or
automatically. PhpStorm supports both modes, let's see how we can work with them.
When working with Drupal sites, the Pantheon Terminus Command-Line Tool can be used to commit site changes to Pantheon as well,
using the pantheon-site-commit.
After selecting the local path we want to clone into and clicking OK, PhpStorm will prompt for a password. We can enter our Pantheon password
and let PhpStorm finish cloning. If the site that has been cloned is a Drupal or WordPress site, PhpStorm will offer framework integration
suggestions.
Before committing, PhpStorm can perform several additional actions for us, like reformatting code, optimizing imports, check if there are TODO
comments in our code and run code analysis.
Clicking the Commit button will provide us with the choice of just committing changes to the local Git repository on our machine, or do a Commit
and Push which will also push our changes back to Pantheon so they can be deployed.
Once pushed, the Pantheon site dashboard will display the commit in our commit log and deploy the changes to the dev environment from where
we can propagate them to other environments using the Pantheon Workflow.
Once selected, we can continue the wizard. In the deployment options screen, pick Default. Next, add a new server and enter the details found in
the Pantheon site dashboard. The following options must be provided:
Server type set to SFTP
SFTP host: from the site dashboard
Port: 2222
Username: from the site dashboard
Password: your Pantheon password
Root path: click Autodetect, then add /code to the end of the detected path
The Web server root URL can be set to the full website URL we're working on. Here's an example of what these settings could look like.
In the Choose Remote Path dialog, click the Project Root button to mark the entire folder as belonging to our project.
Once we finish the wizard, PhpStorm will download the existing site's files and open the project. If the site
By default, only files changed by the IDE will be uploaded. If files are changed by some other process such as transpilation of Sass or
LESS, a File Watcher, or Grunt, they are not automatically uploaded. To change this behavior and autoupload these changes as well,
enable the Upload external changes option.
If it's preferred to upload changes manualy, check the Sync changes and automatic upload to a deployment server in PhpStorm tutorial for more
information about the various options.
Once we've made some changes, we can commit them using the site dashboard.
Drupal
Once a Drupal project has been downloaded from Pantheon, the IDE offers us to enable Drupal integration.
Clicking Enable will let us specify the full path to a Drupal installation. This is used to provide code completion hints while developing. We also
have to specify the Drupal version. Supported versions are Drupal 6, 7 and 8.
We can optionally also enable the Drupal code styles, another suggestion the IDE will offer us.
Once done, PhpStorm provides many features like hook completion and navigation, #Drush Integration, searching in the Drupal API
documentation, Coder and PHP Code Sniffer support, and many more features that are available in PhpStorm. Check the Drupal Development
using PhpStorm tutorial to learn more about the possibilities.
Drush Integration
Drush is a command line shell and scripting interface for Drupal. We can configure Drush as a PhpStorm command line tool and get full support
for invoking Drush commands from the command line tools.
Once configured, we can bring up the command line tool window by selecting Tools | Run Command... or pressing Ctrl+Shift+X (Cmd-Shift-X on
Mac OS X). It provides completion for all possible commands offered by the tool.
To use Drush on Pantheon sites, it is recommended to install the Pantheon Drush aliases. These allow executing Drush commands
against a Pantheon site.
For example, calling drush @pantheon.sitename.envwatchdog-show (as explained here) will watch events like warnings and
errors from the site as they happen.
WordPress
Once a WordPress project has been downloaded from Pantheon, the IDE offers us to enable WordPress integration.
Clicking Enable will let us specify the full path to a WordPress installation. This is used to provide code completion hints while developing, for
example to hooks defined in the various plugins and WordPress base functionality.
Once done, the IDE offers us to enable WordPress code style. We can enable it and continue development.
PhpStorm provides many features like hook completion and navigation, searching on WordPress.org, WordPress Command Line Tool WP-CLI
Integration, PHP Code Sniffer integration and many more features that are available in PhpStorm. Check the WordPress Development using
PhpStorm tutorial to learn more about the possibilities.
PhpStorm does not ship with database drivers installed, but it does provide a handy way of downloading them when needed: click the "
Download ... driver files" link next to the warning about missing drivers to download them.
After testing and saving the database connection details, we can explore, manage, refactor, query and code against our Pantheon database.
To learn more about Databases and SQL Editor in PhpStorm, check this tutorial.
Tweet