1
votes

I'm trying to get debugging using Xdebug and PhpStorm to work. I've set it up several times in the past, without much issues. This time things are not going as smoothly though.

My current configuration in php.ini is as follows:

zend_extension = "c:\xampp2\php\ext\php_xdebug.dll"

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
xdebug.remote_cookie_expire_time=3600
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.idekey=PHPSTORM
xdebug.remote_log="c:\xampp2\tmp\xdebug.txt"

xdebug.remote_autostart=1

Adding xdebug.remote_autostart made sure that connections were being set up whenever a script is being run from the CLI. It still does not work when invoking a script through Apache though.

I have checked the Xdebug log, and I'm not seeing anything unusual there: https://pastebin.com/4rK8pJqt

The most obvious cause would be having separate php.ini files for CLI and Apache, but that is not the case. I only have a single php.ini file, and I have verified that Xdebug settings show up just fine in phpinfo in a browser. Please see below for screenshots.

Are there any specific settings that could cause Xdebug not to be able to connect to PHPStorm? Or is anyone aware of any bugs in either Xdebug or PhpStorm that could cause this?

Xdebug in phpinfo Xdebug in phpinfo

1
it was a long time ago but as i remember there was some browser extension to run xdebug :) - maxs87
I have tried bookmarks, manually setting the cookies, extensions and remote_autostart. None of these work. As you can see in the log, xdebug is setting up a connection successfully. So the issue must be somewhere else. - chocochaos

1 Answers

1
votes

I have identified the issue. Somewhat anyway.

Upon disabling "Ignore external connections through unregistered server configurations" it started working. I then had a look at the server configuration in PhpStorm, which seemed absolutely fine, so I tried it with this setting disabled again, and that worked as well.

PhpStorm setting

So, to fix my issue I had to:

  1. Go to file -> settings.
  2. Go to Languages & Frameworks -> PHP -> Debug.
  3. Uncheck "Ignore external connections through unregistered server configurations".
  4. Run a script to trigger Xdebug from the browser.
  5. Go to settings again and enable the same setting again.

And everything works like a charm now!