Debugger Configuration Validation with PhpStorm

While it’s very straightforward to set up PhpStorm’s debugger, nothing is more frustrating than not getting it to work because of a tiny configuration mistake in php.ini. Speaking for myself, I’ve missed xdebug.remote_enable on a number of occasions, which usually happen at the most inconvenient time.

Using the Debugger Configuration Validation introduced with the latest version of the PhpStorm 7 EAP, we can now easily validate our debugger setup and have PhpStorm tell us if we’ve missed something! PhpStorm can verify our configuration of Xdebug and Zend Debugger. Here’s how.

When configuring the PHP interpreter for our project, PhpStorm will inform us if a debugger is installed and will yield the Xdebug or Zend Debugger version used.

From the Settings | Project Settings | PHP | Servers window, we can validate our debugger setup using the Validate Remote Environment button.

This will open a new window where we can test the deployment environment on which we want to attach the debugger and validate the debugger configuration. This deployment environment can be “In place”, e.g. a local webserver or a remote server which is accessible by PhpStorm. Once we click Validate, PhpStorm will tell us if anything is missing (and what). Note that it can do that for both Xвebug and Zend Debugger.

There we are! I missed xdebug.remote_enable again. If we select different options in PhpStorm from our deployment environment, Debugger Validation Configuration will detect that:

If we’ve configured everything correctly, PhpStorm will be happy to tell:

This new feature will save some time trying to figure out what is wrong with the debugger configuration. Give PhpStorm 7 EAP a try and as always, let us hear your thoughts in the issue tracker, through the comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

This entry was posted in Cool Feature, Early Access Program and tagged , , , . Bookmark the permalink.

30 Responses to Debugger Configuration Validation with PhpStorm

  1. Paul Redmond says:

    I’ve been looking around for an existing issue or request for adding Xdebug links for PHPStorm. It would be really awesome the click links in the browser and go directly to an exception.

    • Sebastien Collado says:

      You can try “Remote Call” plugin to emulate this feature : http://plugins.jetbrains.com/plugin/6027?pr=phpStorm

    • Marcel Anacker says:

      There are already several ways to do this.
      One is described here, using the Remote Call plugin and an AJAX request:
      https://github.com/computerminds/parrot/wiki/PHP-XDebug

      Another way, which I use on Windows works as follows: (couldn’t find the original blog post)
      - Create a script which runs PHPStorm.exe with the given parameters

      var editor = '"C:\\Program Files (x86)\\JetBrains\\PhpStorm 130.1481\\bin\\PhpStorm.exe" --line %line% "%file%"';

      var url = WScript.Arguments(0);
      var match = /^editor:\/\/open\/\?file=(.+)&line=(\d+)$/.exec(url);
      if (match) {
      var file = decodeURIComponent(match[1]).replace(/\+/g, ' ');
      var command = editor.replace(/%line%/g, match[2]).replace(/%file%/g, file);
      var shell = new ActiveXObject("WScript.Shell");
      shell.Exec(command.replace(/\\/g, '\\\\'));
      }

      - Create a custom protocol handler via the following registry file:

      REGEDIT4

      [HKEY_CLASSES_ROOT\editor]
      @="URL:editor Protocol"
      "URL Protocol"=""

      [HKEY_CLASSES_ROOT\editor\shell\open\command]
      @="wscript \"C:\\dev\\editor.js\" \"%1\""

      - Add the following line to your xdebug config:

      xdebug.file_link_format="editor://open/?file=%f&line=%l"

  2. Paul Redmond says:

    Oh, and the debugging feature is a really nice addition. I’ve ran into trouble here and there helping set others up with XDebug, and this will be really handy for troubleshooting.

  3. Serge Baranov says:

    There is a typo: “Remote debug is not enable”.

  4. Henning Kvinnesland says:

    There is a way. Format your exceptions correctly and use this plugin: http://plugins.jetbrains.com/plugin/6027?pr=phpStorm.

  5. Andriy Bazanov says:

    Will it recognize situation when both Zend Debugger as well as Xdebug (or any other debugging engines) are enabled/loaded in php.ini ?

    This is not a rare situation when new users trying to debug PHP code, especially when they are new to this.

  6. Good day! I know this is kinda off topic but I was wondering if
    you knew where I could locate a captcha plugin for my comment form?
    I’m using the same blog platform as yours and I’m having trouble finding one?
    Thanks a lot!

  7. Joe Kaiser says:

    Any idea why I’d get a “Failed to execute validation script” error?

  8. S.Shevchuk says:

    Same problem “Failed to execute validation script” error
    Win7

  9. gafreax says:

    I’ve some trouble with debuggin zf2 app: I solved setting local path and remote root path to :
    c:\www\my_project\public
    and
    /var/www/my_project/public

  10. Anton Larsen says:

    running a php script (commandline) with debugging enabled does not seem to work for me.

    It says “Connection with ‘xdebug’ was not established. Validate installation”. And when i click validate installation i get: “Cannot parse configuration file”.

    Xdebug does work with PHPUnit though.

    • Svetlana Zemlyanskaya says:

      Please, check if debugger extension is detected by PhpStorm (Settings | PHP | Interpreters) and check the result of detection with phpinfo() output. In case you’ll find some differences (e.g. phpinfo() shows that debug extention is loaded, but PhpStorm can’t detect it) report new issue: http://youtrack.jetbrains.com/issues/WI

  11. Paul says:

    Hello

    Running nginx in a Vagrant box, with my xdebug config in a separate xdebug.ini file. Running phpinfo confirms that the xdebug config is loaded but PHPStorm still issues warning that xdebug.remote_enable isn’t set in php.ini.
    How do I get it to recognize my external config file?

  12. Will Melbourne says:

    How do we set the PHP location when it is installed in vagrant so isn’t accessible from the same directory structure?

    Thanks

    • Will Melbourne says:

      Apologies that should read

      How do we set the PHP location when it is installed in vagrant as isn’t accessible from the same directory structure? As far as I can tell the only files of the vagrant guest machine which are accessible are the shared directory. System files like the PHP folder location don’t seem to be available.

      Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">