Created by: gwideman, Nov 18, 2011 5:16 am
Revised by: gwideman, Jan 30, 2012 3:13 am (14 revisions)

Overview

Installation of JetBrains PHPStorm, the installation of XDebug, and configuration for debugging Drupal.

Install JetBrains PHPStorm

  • Downloaded trial PHPStorm 2.1: http://www.jetbrains.com/phpstorm/
  • Installed no problem
  • Initial test
    • Created simple one-file php program
      • <?php
        echo "this is a test";?>
    • Running from IDE requires configuring path to php.exe
    • Run fails: "Process finished with exit code -1073741515"
    • Winkle: As configured by Acquia, in the php home directory, there's also a php.cmd file that sets a path to php5ts.dll (in apache\bin). I guessed that PhpStorm calls php.exe, not php.cmd, so the necessary path to the dll doesn't get set. So I set that in Windows PATH. (Probably it could be set somewhere more temporary, but I was in a hurry.)
    • Run of simple program from PhpStorm still fails
    • Oooops! Have to exit and restart PhpStorm for its environment to get new PATH.
      • Now run succeeds!

Running PHP from command line

While troubleshooting the above, I attempted to run php.exe from command line. After getting the PATH set right (see above), the following commands ran OK from Windows command line window:
  • php -m (shows modules)
  • php -v (shows version info)
But interactive mode (php -a) didn't work properly. Showed "Interactive mode" message, but would not accept input. This apparently is due to library readline not being included (and missing from the php -m listing).
This isn't fatal, we're not really interested in command line mode anyway. PhpStorm seems able to interact with php.exe, so OK.

Installing XDebug

2011-11-18 version

  • Visited http://www.xdebug.org/index.php
  • Ran the "tailored installation instructions" here: http://www.xdebug.org/find-binary.php
    • This calls for a phpinfo listing. Drupal root dir contains phpinfo.php, whose output I copied/pasted to xdebug.org's form.
    • Instructions tell to:
      • Download php_xdebug-2.1.2-5.2-vc6.dll
      • Move the downloaded file to D:\wwwtest_stack\acquia-drupal\php\ext
      • Edit D:\wwwtest_stack\acquia-drupal\php\php.ini and add the line
        • zend_extension_ts = D:\wwwtest_stack\acquia-drupal\php\ext\php_xdebug-2.1.2-5.2-vc6.dll
        • NOTE: it's not clear exactly what section of php.ini to stick this in. I put it in the end of the [PHP] section after the many extension= entries.
      • Restart the webserver
      • OK, done
  • I later noticed that php -v command showed XDebug info. Seems promising.

2012-01-28 version

  • Following new install of Acquia Drupal which includes PHP 5.3.8....
  • Tailored instructions:
    • Download php_xdebug-2.1.3-5.3-vc9.dll
    • Move the downloaded file to D:\wwwtest_stack\php5_3\ext
    • Edit D:\wwwtest_stack\php5_3\php.ini and add the line
      [PHP]
      zend_extension = D:\wwwtest_stack\php5_3\ext\php_xdebug-2.1.3-5.3-vc9.dll
    • Restart the webserver
  • [to be completed]

Configuring a PhpStorm project to allow debugging Drupal

  • I followed instructions here: Creating New Project from Existing Source Code
    • File > Open Directory
    • Select the webroot of the Drupal site configured earlier: D:\wwwtest\sites\drupal01
    • OK.
    • RELATED INFO FOR LATER: Project organisation for Drupal
  • PhpStorm analyzes the directory tree.
    • Shows directory tree in left pane.
    • Opening a php file to browse works, and so does right-click > goto > declaration
  • Debugging configuration
    • File > Settings
      • Project Settings > PHP > Servers
        • Name: whatever, I used drupal01
        • Host: drupal01 Port: 8082 Debugger: XDebug
    • Run > Edit Configurations
      • Add config [+] for PHP Web Application.
        • Name (whatever.... drupal01debug)
        • Server: pick the recently config'ed drupal01 off the drop-down list
        • Start URL:
          Browser: Pick one off list (Firefox)
        • Debug: maybe check [ ] Break at first line
        • Apply, OK
  • Attempted to debug.
    • Launches page in FF, FF URL shows ?XDEBUG_SESSION_START=16325 but doesn't stop on first line of file.
      • Debugger output shows "Waiting for incoming connection with ide key '16325 ' "
      • Possibly because URL was "/" and it doesn't know what file that is for breaking? Changed run file to /index.php. No change in symptoms
    • Possibly useful pages:
      • Post on netbeans site: Howto check xdebug installation
        • Suggestion: might need to uncomment "extension=php_sockets.dll" in my php.ini file.
          • Sure enough, sockets is commented out, and php_sockets.dll is not included in Acquia install. Hmm, could that be it?
          • Turns out not
        • Suggestion: there should be some XDebug config lines in php.ini see: http://www.xdebug.org/docs/remote#activate_debugger,"Starting the debugger". Following lines did the job:
          • xdebug.remote_enable=1
            xdebug.remote_handler=dbgp
            xdebug.remote_host=localhost
            xdebug.remote_port=9000
            xdebug.remote_log=D:\\wwwtest_stack\\logs\xdebug.log
        • After applying these, debugging breakpoints (and "stop on first line") worked as expected.