PhpStorm DevelopingonPantheonwithPhpStorm 200116 0029 2494

Post on 15-Apr-2016

29 views 6 download

description

Developing on Pantheon with PhpStorm

Transcript of PhpStorm DevelopingonPantheonwithPhpStorm 200116 0029 2494

Developing on Pantheon with PhpStorm 

Getting StartedGetting Started with Pantheon Git Mode

Cloning the Pantheon Git repositoryMaking a Change and Committing to Pantheon

Getting Started with Pantheon SFTP ModeCreating a Project using SFTPDeploying Local Changes to Pantheon using SFTPExploring the Site Filesystem

Enabling Framework IntegrationDrupal

Drush IntegrationPantheon Terminus Command-Line Tool Integration

WordPressManaging the Pantheon Database with PhpStorm

If you prefer a video over a tutorial, here's a quick introduction to using PhpStorm and Pantheon.

Getting StartedFor this tutorial, we'll assume a site has already been created on Pantheon. in the Pantheon docs explaining how to create aA tutorial is availablesite.

Pantheon provides two ways of working with the platform. We can connect , develop locally and push changes to Pantheon once weusing Gitwant them to go live. The other way of working is where we deploy our changes on the Pantheon servers directly, either manually orusing SFTPautomatically. PhpStorm supports both modes, let's see how we can work with them.

Getting Started with Pantheon Git Mode

When working with Pantheon's , we can use PhpStorm to commit, push and pull changes from our site.Git Mode

Cloning the Pantheon Git repository

From the PhpStorm welcome screen, use the option (or use the Checkout from Version Control | Git VCS | Checkout from Version Control | menu). We can enter our Pantheon's Git repository details, which are found on our site's dashboard, in the dialog that opens. The Git URLGit

typically looks similar to .ssh://codeserver.dev.someguid@codeserver.dev.someguid.drush.in:2222/~/repository.git

Tweet

Pantheon is a hosting platform, providing best practices for developing,hosting and maintaining Drupal and WordPress web applications. Itprovides hosting, database, caching, version control, development,staging, test and production environments, backups and workflows formoving an application through the development pipeline.

In this tutorial, we'll take a look at how we can use PhpStorm to developDrupal and WordPress applications on Pantheon.

When working with Drupal sites, the can be used to commit site changes to Pantheon as well,Pantheon Terminus Command-Line Toolusing the .pantheon-site-commit

Check the tutorial for more information about PhpStorm's support for version controlVersion Control Systems Support in PhpStormsystems like Git.

After selecting the local path we want to clone into and clicking , PhpStorm will prompt for a password. We can enter our Pantheon passwordOKand let PhpStorm finish cloning. If the site that has been cloned is a Drupal or WordPress site, PhpStorm will offer framework integration

.suggestions

Making a Change and Committing to Pantheon

We can work on our website in PhpStorm. All changes made can be committed to Git. We can do this using the keyboard shortcut (Ctrl+K CMD+ on Mac OS X). PhpStorm will present us with a dialog where we can review the changes we made and add a description to the commit.K

Before committing, PhpStorm can perform several additional actions for us, like reformatting code, optimizing imports, check if there are TODO in our code and run code analysis.comments

Clicking the button will provide us with the choice of just committing changes to the local Git repository on our machine, or do a Commit Commit which will also push our changes back to Pantheon so they can be deployed.and Push

Once pushed, the Pantheon site dashboard will display the commit in our commit log and deploy the changes to the environment from wheredevwe can propagate them to other environments using the .Pantheon Workflow

Getting Started with Pantheon SFTP Mode

Pantheon lets us develop our code where we deploy our changes on the Pantheon servers directly, either manually or automatically.using SFTPLet's see how we can get our site copied to our machine so we can start working on it.

Creating a Project using SFTP

From the welcome screen, select the option. Alternatively, use the TODO menu.Create New Project From Existing Files

In the next screen, select the option.Web server is on remote host, files are accessible via FTP/SFTP/FTPS

Once selected, we can continue the wizard. In the deployment options screen, pick . Next, add a new server and enter the details found inDefaultthe Pantheon site dashboard. The following options must be provided:

Server type set to SFTPSFTP host: from the site dashboardPort: 2222Username: from the site dashboardPassword: your Pantheon passwordRoot path: click , then add to the end of the detected pathAutodetect /code

The can be set to the full website URL we're working on. Here's an example of what these settings could look like.Web server root URL

In the dialog, click the button to mark the entire folder as belonging to our project.Choose Remote Path Project Root

Once we finish the wizard, PhpStorm will download the existing site's files and open the project. If the site

is a Drupal or WordPress site, PhpStorm will offer .framework integration suggestions

Deploying Local Changes to Pantheon using SFTP

Since Pantheon's SFTP mode encourages on-server development, it's good practice to open PhpStorm's settings and under Build, Execution, set to . This will ensure that PhpStormDeployment | Deployment | Options Upload changed files automatically to the default server Always

always uploads changes that were made locally directly to the Pantheon server.

If it's preferred to upload changes manualy, check the tutorial for moreSync changes and automatic upload to a deployment server in PhpStorminformation about the various options.

Once we've made some changes, we can commit them using the site dashboard.

By default, only files changed by the IDE will be uploaded. If files are changed by some other process such as transpilation of Sass orLESS, 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

Exploring the Site Filesystem

PhpStorm comes with drag & drop as well as copy & paste support from the project pane to the Remote Host tool window. To be able to use this,open the Remote Host tool window using the menu.Tools | Deployment | Browse Remote Hosts

Files and folders can be copied (or moved) from and to the deployment server using drag-and-drop. This functionality behaves like it does on ourcomputer: by default, the selected item will be moved. When holding the key when dropping, the file or folder will be copied instead.Ctrl

Enabling Framework IntegrationPantheon focuses on Drupal and WordPress development, two frameworks fully supported by PhpStorm. Once a project has been downloaded toa developer machine, the IDE will recognize the application type and propose enabling framework-specific support. Let's see.

Drupal

Once a Drupal project has been downloaded from Pantheon, the IDE offers us to enable Drupal integration.

Clicking will let us specify the full path to a Drupal installation. This is used to provide code completion hints while developing. We alsoEnablehave 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, , searching in the Drupal API#Drush Integrationdocumentation, Coder and PHP Code Sniffer support, and many more features that are available in PhpStorm. Check the Drupal Development

tutorial to learn more about the possibilities.using PhpStorm

Drush Integration

Drush is a command line shell and scripting interface for Drupal. We can and get full supportconfigure Drush as a PhpStorm command line toolfor invoking Drush commands from the command line tools.

Once configured, we can bring up the command line tool window by selecting or pressing ( onTools | Run Command... Ctrl+Shift+X Cmd-Shift-X). It provides completion for all possible commands offered by the tool.Mac OS X

To use Drush on Pantheon sites, it is recommended to install the Pantheon . These allow executing Drush commandsDrush aliasesagainst a Pantheon site.

For example, calling (as explained ) will watch events like warnings anddrush @pantheon.sitename.envwatchdog-show hereerrors from the site as they happen.

Pantheon Terminus Command-Line Tool Integration

The can be installed into our site and executed with Drush. After installing Terminus, open the PhpStormPantheon Terminus Command-Line Toolsettings and refresh the Drush command line tool commands list from the section. Once done, the DrushTools | Command Line Tools Supportcommand line tool completion in PhpStorm will provide all Pantheon-specific commands. We can execute them from within the IDE.

WordPress

Once a WordPress project has been downloaded from Pantheon, the IDE offers us to enable WordPress integration.

Clicking will let us specify the full path to a WordPress installation. This is used to provide code completion hints while developing, forEnableexample 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-CLIIntegration, PHP Code Sniffer integration and many more features that are available in PhpStorm. Check the WordPress Development using

tutorial to learn more about the possibilities.PhpStorm

Managing the Pantheon Database with PhpStormEvery Pantheon site comes with a database, which we can manage from within PhpStorm. The IDE can help us perform all types of routinedatabase tasks, such as querying for a record; checking what that column was named again; database development where we have to create theschema structure and more. PhpStorm also provides code completion on table names and columns, while writing PHP code!

All we have to do is setup a connection to our Pantheon database. From the menu, open the Database tool window andView | Tool Windowsuse the green icon in the toolbar to create a new data source. Pick as the database type. PhpStorm will ask us for+ Data Source | MySQLconnection information, which we can find on the Pantheon site dashboard. Here's an example configuration:

After testing and saving the database connection details, we can explore, manage, refactor, query and code against our Pantheon database.

PhpStorm does not ship with database drivers installed, but it does provide a handy way of downloading them when needed: click the " ... driver files" link next to the warning about missing drivers to download them.Download