PHP Debugging in PHPStorm 6.0 with Xdebug

Article Primary image
Author Image - Phil Middlemass

By Phil Middlemass

Our Creative Director giving his opinion on 17 years in the digitial industry working with leading brands and companies

We've been using JetBrains PHPStrom 6.0 for PHP development for a while now, and quite frankly it's best PHP IDE we have used. However one important out-of-the-box feature of PHPStorm takes a little extra work to configure, Debugging. Follow our quick and simple tutorial to get Xdebug up and working with PHPStorm.

We're going to concentrate on setting up debugging in PHPStrom using Windows 8 64bit with PHP 5.5 (64bit VC11) for this tutorial, the only real difference between the various OS's is the Xdebug extension you download and install.

Getting Xdebug installed

For this first part, download the correct version of the Xdebug DLL, for my server setup I needed to download the PHP 5.5 VC11 (64 bit) DLL to correspond to my PHP installation. Be sure to download the correct version of Xdebug for your PHP installation and whether you need the thread-safe (TS) or Non thread-safe version.

The downloaded DLL file needs to be saved to your configured PHP extensions folder and the following code added to your servers php.ini congifuration file:


zend_extension="C:\Program Files\PHP_x64\ext\php_xdebug-2.2.3-5.5-vc11-nts-x86_64.dll"

The key settings to note in the php.ini code above are the full path for the zend_extension (this needs to amended to point to your own ext/ folder) and the xdebug.idekey set to PHPSTORM

Create a new PHP file on your web server with the following code to test if you have successfully installed Xdebug:



If Xdebug is successfully installed you will see a section of the phpinfo(); output similar to this:

phpinfo() Output
phpinfo() Output

Setting up a browser to handle debug sessions

My browser of choice for development is Google Chrome, and there are a few Xdebug extensions for Chrome that you could install and use. Personally I useXdebug helper, it's unobtrusive and easy to configure for PHPSTORM.

Xdebug Helper
Xdebug Helper

Once installed a simple Xdebug icon appears to the right of the Chrome address bar, and allows simple enabling/disabling of Xdebug sessions in the browser.

Next you need to configure the IDE Key for Xdebug Helper to use. This can be configured in the "Options" link accessed from within the Chrome Extensions panel for Xdebug Helper.

You will need to select "Other" from the drop down list and enter "PHPSTORM" in the text field, then hit the save button (a floppy disc! rocking like it's 1999 ...)

Xdebug Helper Options
Xdebug Helper Options

Debugging in PHPStorm

Because we are using Xdebug Helper from within the browser to handle our debug session all we need PHPStorm to do is listen for the incoming debug connections. You can do this by simply toggling the "Start listen PHP debug connections" button in PHPStorm.

PHPStorm Debug Listener
PHPStorm Debug Listener

Then with the Xdebug Helper extension enabled in Chrome we can start to set some break points in PHPStorm.

Enter break points where ever you want to inspect the current execution state of your code.

PHPStorm Break points
PHPStorm Break points

Reload your web page, and if all is setup correctly PHPStorm should become active after detecting an incoming debug connection. Whenever you first run a new site in PHPStorm with a debug session, it will ask you to confirm the "Path Mapping" for the incoming connection, generally you just need to accept the default selection and the debugging session kicks into full swing.

PHPStorm Debugging
PHPStorm Debugging

Annoying debug session timeouts

In Windows IIS7+ when you setup PHP to run via FastCGI it configures a default Activity_Timeout parameter which is used as a timeout counter for PHPStorm debug sessions. If your Activity_Timeout variable is set too low you maybe left frustrated like me by the short amount of time you have to analyse your breakpoint variables and edit your code.

Setting a longer Activity_Timeout variable

Assuming you are running PHP under IIS7+ as FastCGI do the following:

  1. Start IIS Manager
  2. Double click on the FastCGI Settings icon on your server root node
  3. Double click on your PHP FastCGI application path entry
  4. In the Edit window that appears, locate and change the Activity Timeout parameter to your desired time in seconds. I have mine set to 300 second to give me 5 minutes before timing out.
IIS FastCGI Settings
IIS FastCGI Settings

And that's it, PHP debugging in PHPStorm with Xdebug.