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:
- Open the Acquia Dev Desktop > Preferences menu.
- In the Config tab, under Stack configuration files, find the
php.inipath for the version of PHP that you are using, and then click the Edit link next to it.
php.inifile will open in a text editor. Search for a line that contains
xdebug.soand uncomment it by removing the
;(semicolon) at the beginning of the line. For example:
For the following PHP versions in Acquia Dev Desktop for Windows, enter the following filenames in place of
- PHP 5.3 -
- PHP 5.4 -
- PHP 5.5 -
- PHP 5.6 -
- PHP 5.3 -
- Add the following line to your
- 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
- Download PhpStorm from JetBrains and install it. JetBrains offers a free 30-day trial. See the PhpStorm documentation for more information.
- 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.
- Add your Acquia Dev Desktop website as a project in PhpStorm.
- Configure remote debug.
Configure PhpStorm to use Xdebug
- In PhpStorm, go to the PhpStorm > Preferences menu.
- Under Project Settings, expand PHP.
- 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.
- Click OK to save your changes.
- Go to View and click Toolbar, which has an icon for turning listening on and off:
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.
- In the File menu, click Open.
- 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:
- In the Run menu, select Edit Configurations.
- In the Run/Debug Configurations window, click the plus sign + to add a new configuration, and then select PHP Remote Debug.
- In the Name field, provide a meaningful name.
- Click the box next to the Server list to add a new server.
- Provide a meaningful name for the server.
- Add the hostname and port that your local website uses under Acquia Dev Desktop.
- Ensure that the Debugger selector is set to Xdebug.
- Click OK to save your server configuration.
- 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.
To set breakpoints in your code, complete the following steps:
- Load your Acquia Dev Desktop Drupal website in the browser where you created the PhpStorm debugger bookmarklets.
- Click the Start Debugger bookmarklet.
- In the PhpStorm toolbar, click the Listen icon . The icon will change to to indicate that PhpStorm is now listening for connections.
- In PhpStorm, open your project and go to the file that contains the code where you want to set a breakpoint.
- Click in the column to the left of the code to set a breakpoint (or enter Command-F8).
PhpStorm indicates the presence of a breakpoint with an icon in the left margin and highlighting on the code line.
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:
As you run your code with the debugger, these buttons in the Debugger tab can be useful for you:
- Step Over - Step to the next line in the current file. See Stepping Through the Program.
- Step Into - Step to the next executed line. See Stepping Through the Program.
- Force Step Into - Select the method to step in, if the current line contains multiple method call expressions. See Choosing a Method to Step Into.
- Step Out - Step to a first executed line after returning from the current method. See Stepping Through the Program.