Using PhpStorm with Acquia Dev Desktop

PhpStorm from JetBrains is an IDE for PHP and Drupal that can be immensely useful in developing, testing, and debugging a Drupal website. It includes both a rich code editor and a visual debugger supporting Xdebug. This topic describes how to set up PhpStorm to support developing your Drupal website with Acquia Dev Desktop. For a summary of some of the benefits of using PhpStorm, see Using PhpStorm with Drupal.

Before you begin, you should have installed Acquia Dev Desktop and have a Drupal website running locally in Acquia Dev Desktop.

Configuring Acquia Dev Desktop with Xdebug

The Xdebug PHP extension is included in Acquia Dev Desktop, but it is not enabled by default. To use the Xdebug debugger in PhpStorm with Acquia Dev Desktop, you will need to edit the php.ini file in Acquia Dev Desktop to enable and configure Xdebug. To do this, complete the following steps:

  1. Open the Acquia Dev Desktop > Preferences menu.
  2. In the Config tab, under Stack configuration files, find the php.ini path for the version of PHP that you are using, and then click the Edit link next to it.

    Edit your php.ini file

  3. Your php.ini file will open in a text editor. Search for a line that contains xdebug.so and uncomment it by removing the ; (semicolon) at the beginning of the line. For example:

    zend_extension="/Applications/DevDesktop/php5_5/ext/xdebug.so"

    For the following PHP versions in Acquia Dev Desktop for Windows, enter the following filenames in place of xdebug.so:

    • PHP 5.3 - php_xdebug-2.2.4-5.3-vc9.dll
    • PHP 5.4 - php_xdebug-2.3.2-5.4-vc9.dll
    • PHP 5.5 - php_xdebug-2.3.2-5.5-vc11.dll
    • PHP 5.6 - php_xdebug-2.3.2-5.6-vc11.dll
  4. Add the following line to your php.ini file:

    xdebug.remote_enable=1
  5. Stop and restart Apache in Acquia Dev Desktop to ensure that the configuration change takes effect.

You can confirm that Xdebug is enabled by visiting the Drupal phpinfo() page (/admin/reports/status/php) and verifying that the Xdebug extension appears in the list of extensions.

Installing and configuring PhpStorm

  1. Download PhpStorm from JetBrains and install it. JetBrains offers a free 30-day trial. See the PhpStorm documentation for more information.
  2. On the PhpStorm bookmarklets generator page, generate Xdebug bookmarklets ("start debugger," "stop debugger," and "debug this page"), and add them to your browser.

Next, do the following:

Configure PhpStorm to use Xdebug

  1. In PhpStorm, go to the PhpStorm > Preferences menu.
  2. Under Project Settings, expand PHP.
  3. Click Debug. In the Xdebug section, select Can accept external connections. Confirm that the Debug port is set to the default value of port 9000.
  4. Click OK to save your changes.
  5. Go to View and click Toolbar, which has an icon for turning listening on and off:

    The listen icon in the PhpStorm toolbar

Add your Acquia Dev Desktop website as a project

To use PhpStorm with an Acquia Dev Desktop website, you need to add the website's code as a project.

  1. In the File menu, click Open.
  2. Select the website's local code directory, and click Choose.

Configure remote debug

You need to configure a new remote debug server for each Drupal website project that you open in PhpStorm. To configure it:

  1. In the Run menu, select Edit Configurations.
  2. In the Run/Debug Configurations window, click the plus sign + to add a new configuration, and then select PHP Remote Debug.

    Remote debug configuration

  3. In the Name field, provide a meaningful name.
  4. Click the box next to the Server list to add a new server.

    Configure a debug server

  5. Provide a meaningful name for the server.
  6. Add the hostname and port that your local website uses under Acquia Dev Desktop.
  7. Ensure that the Debugger selector is set to Xdebug.
  8. Click OK to save your server configuration.
  9. Confirm that your new server is selected in the Server list, and then click OK to save.

Using Xdebug in PhpStorm

You can use Xdebug with PhpStorm to debug your Acquia Dev Desktop Drupal website. You first set breakpoints in your code, and then run your code and see the results in PhpStorm.

Set breakpoints

To set breakpoints in your code, complete the following steps:

  1. Load your Acquia Dev Desktop Drupal website in the browser where you created the PhpStorm debugger bookmarklets.
  2. Click the Start Debugger bookmarklet.
  3. In the PhpStorm toolbar, click the Listen icon PhpStorm listen icon. The icon will change to PhpStorm listening icon to indicate that PhpStorm is now listening for connections.
  4. In PhpStorm, open your project and go to the file that contains the code where you want to set a breakpoint.
  5. Click in the column to the left of the code to set a breakpoint (or enter Command-F8).

    Setting a breakpoint

PhpStorm indicates the presence of a breakpoint with an icon in the left margin and highlighting on the code line.

Breakpoint is set

Run your code and see the results

Once debugging is turned on, and PhpStorm is set up to listen, perform an action on the website. When the breakpoint is hit, PHP execution will stop, and a Debug window will appear:

Using Xdebug

As you run your code with the debugger, these buttons in the Debugger tab can be useful for you:

Contact supportStill need assistance? Contact Acquia Support