6

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

2
  • it was a long time ago but as i remember there was some browser extension to run xdebug :) Commented Nov 10, 2017 at 12:42
  • 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. Commented Nov 10, 2017 at 12:45

1 Answer 1

9

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!

Sign up to request clarification or add additional context in comments.

3 Comments

this worked for me in 2024 IntelliJ. 🙇
This answer works for me with PHPStorm+Docker. Thank you!
Even this fix stopped working for me today. So, I checked "Break at first line in PHP scripts" in Debug settings and it works. It immediately stops at first line and you have to click "Resume Program" in debug window so that it starts execution (until it encounters a breakpoint).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.