3

I am using Wamp on Windows 10 Pro 64bit. Firstly, PHP XDebug based debugging works fine on my normal Core PHP application in Visual Studio Code but when I start debugging a PhalconPhp (MVC) based application it stops at the first breakpoint and doesn't proceed, whatever I try - Continue (F5), Step Over (F10) etc. None of the keys or options work.

I have checked all similar issues and solutions - tried changing port from default 9000 to 9001 in php.ini and launch.json, added all extra configurations suggested in various posts although I am not doing remote debugging. Tried to setup a single and multiple breakpoints and also tried keeping them on various lines at start, middle or end of code.

php.ini

xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=1

xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="R:/Temp"
xdebug.show_local_vars=1
xdebug.remote_port = 9000
xdebug.remote_log=R:\Temp\xdebug.log

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

There are no error messages. The debugger doesn't move an inch and stays stuck at first breakpoint. I can only restart execution in debugger, none of the other operations (Step In, Step Over, Continue...) work. I also have xdebug.log but don't see anything useful in it.

UPDATE: Debugging is working well for all Php programs including Phalcon with VSCode 1.36.1, XDebug 2.6.1, Php 7.2.14 on Windows 10. I think VSCode and XDebugger have some incompatibility issue for newer versions, but not sure.

Amal
  • 41
  • 1
  • 6
  • 1
    Do you have any active watches? I'm having that behavior when I have some not available variables in watch (they were added when debugging a different piece of code) – Juanmi Sosso Jan 16 '20 at 14:04
  • I don't remember if I had active watches when I faced this issue, most probably not. It's got resolved. It started working itself. The primary thing I found is that **show_local_vars = 1** and **remote_enable = 1** have to be set for it to work. I saw another post which said **show_local_vars = 9**. Works with that too. – Amal Jan 18 '20 at 01:11
  • Current Solution: I believe people are accessing this, so sharing: I downloaded the latest XDebug DLL 2.9.6 & VSCode Ver 1.46.1 when my debugging again stopped working. I raised the issue with developer of Php Debugger extension for VSCode [Debugging stopped working with Php framework Phalcon](https://github.com/felixfbecker/vscode-php-debug/issues/413) but got no response. I believe the developer is not supporting it now. My debugging works perfectly for core Php and Phalcon programs with Php 7.2.14, VSCode Ver 1.36.1 and XDebug Ver 2.6.1 on Windows 10. It didn't work with Php 7.3 & 7.4. HTH – Amal Oct 21 '20 at 11:55

2 Answers2

-1

In Setting->Debug you should uncheck "Break at first line in PHP scripts" item, this setting is for phpstorm but I think that's same for other IDE.

UPDATE

For VS code:

The launch.json file has the setting "stopOnEntry":true. Change this to false to prevent this. The docs for this can be found code.visualstudio.com/docs/python/debugging#_stoponentry

nima
  • 502
  • 5
  • 14
  • There's a similar setting in Eclipse too. – Paul T. Jul 03 '19 at 01:11
  • Sorry @nima I couldn't find that setting in VSCode, I rechecked. I hope you also understood the issue, it is NOT stopping at the first line but at the **first breakpoint** - whichever line it is on. – Amal Jul 03 '19 at 13:45
  • yes I understood you the only option that cause the debug stop in first break point is that what i say – nima Jul 06 '19 at 07:58
  • 1
    `TRY THIS:` The launch.json file has the setting "stopOnEntry":true. Change this to false to prevent this. The docs for this can be found https://code.visualstudio.com/docs/python/debugging#_stoponentry – nima Jul 06 '19 at 09:42
-1

I started using VS Code debuging php (wordpress) recently. When I enable multiple breakpoints, it sometimes stuck like you described. When I enable only one breakpoint at any moment, it seems worked smoothly. Though it is not without hassle, it is better than no solution. I guess that when mutliple threads hit break points, they all try to talk to the xdebug and somehow deaklocked.