0

I recently tried to switch from PHP 7 to PHP 8, but I'm having trouble with Xdebug behaving oddly.

Basically step-sequencer seems to hit just fine. Variables view does show $_COOKIE and $_SERVER variables, but whenever I assign an variable, such as $i = 0; step debug seems to somehow fail or disconnect. After few seconds browser tries to reload script and step sequencer is hit again.

Some steps seem to work. For example:

<?php 
echo "is it working?";
die();
$i = 0;

... results to "is it working?" output, but if I move the die(); to come after setting $i, script seems to somehow fail and restart. Browser displays "This site can't be reached".

I haven't been able to produce any errors to any logs or such. Any idea what could be causing this? No such issues on PHP 7 and older version of Xdebug.

Edit: Added copy of xdebug.txt (single loading round, starts looping if page refresh hits) and php.ini xdebug-section. Please see here : https://controlc.com/b215b1f1

Janne
  • 1,111
  • 3
  • 12
  • 17
  • What is in the Xdebug log? And if there isn't one, set `xdebug.log=/tmp/xdebug.log` to create one. – Derick Oct 05 '21 at 10:55
  • I removed two lines from this, which contained variables for $_COOKIE and $_SERVER values, but this shows that $i is logged. Nothing after $i-variable & no errors. https://pastebin.com/ZRdxmNKz – Janne Oct 05 '21 at 11:10
  • Additionally I was able to switch back to PHP 7 (using two xampp-installations). I'v tried to make sure that when using PHP8 installation it's really using PHP8, simply by renaming old xampp-installation path so that global enviromental PHP-path wouldn't be mixed between 7 & 8, but I'm quite sure anyway that this ain't the problem because if I disable xdebug then everything works ok, even my big Laravel project... but this most simple snippet fails to display variables. when jumping... and additionally, if there is anything after setting $i, step-seq never reaches there – Janne Oct 05 '21 at 11:17
  • Also tried updating to latest PhpStorm-version – Janne Oct 05 '21 at 11:19
  • For reference purposes: the same on PhpStorm Forums (has a gif showing how it works there): https://intellij-support.jetbrains.com/hc/en-us/community/posts/4407744683922-Xdebug-3-PHP-8-0-11-xdebug-fails-at-variable- For me this looks like Xdebug is crashing for some reason. – LazyOne Oct 06 '21 at 11:42
  • Can you try debugging in a CLI environment (use "PHP Script" type of Run/Debug configuration instead). https://www.jetbrains.com/help/phpstorm/debugging-a-php-cli-script.html#starting-debugging-session Does it work here using your current PHP interpreter from XAMPP? – LazyOne Oct 06 '21 at 11:46
  • 1
    Works for me in CLI environment (using [PHP 8.0.11 x64 NTS](https://windows.php.net/downloads/releases/php-8.0.11-nts-Win32-vs16-x64.zip) + [Xdebug 3.1.0](https://xdebug.org/files/php_xdebug-3.1.0-8.0-vs16-nts-x86_64.dll) -- just download PHP, unpack into some folder, place xdebug file into `ext` folder there, then make a copy of `php.ini-development` -- name it `php.ini`, open that new `php.ini` and add `zend_extension=PATH_TO_YOUR_PHP_FOLDER\ext\php_xdebug-3.1.0-8.0-vs16-nts-x86_64.dll`, save, check that it works with `php -v` and add it as an interpreter in PhpStorm. – LazyOne Oct 06 '21 at 11:47
  • If the above works in CLI.. then need to check what PHP you have got there in your XAMPP (most likely that would be TS version) and how it works there/if you have correct Xdebug etc. – LazyOne Oct 06 '21 at 11:49
  • Thanks for tips. I noticed that I'm using Thread Safe build of PHP8, so that's a minor difference. Double checked that xdebug-version corresponds this build, and it did. Even tried using NTS DLL against my PHP installation, and with no surprise it didn't load up. Phpinfo() does show that xdebug is registered when correct version of DLL is loaded and this corresponds the fact that the step-sequencer is working up to the point described/showed within animation. I'll try older version of XDebug just in case and see how it works. – Janne Oct 07 '21 at 07:37
  • 1
    Will leave the link for Xdebug ticket here: https://bugs.xdebug.org/view.php?id=2030 – LazyOne Oct 08 '21 at 09:50
  • 1
    I believe this is fixed through: https://github.com/xdebug/xdebug/pull/804 — I'll be making 3.1.1 this afternoon. – Derick Oct 15 '21 at 13:16

1 Answers1

0

Problem seems to be either on PhpStorm or Xdebug-3.1.0 Thread Safe version, because switching to Xdebug-3.0.4 started working without problems. Hopefully this gets fixed soon. I'll report this issue & solution to JetBrains as well.

Janne
  • 1,111
  • 3
  • 12
  • 17