vscode-php-debug: VS Code not stopping on breakpoints

I have done a lot of web searching and found many with this issue. I tried all the various fixes to no avail.

I’m running Uniserver on the same machine I’m using VS Studio on. I used the setup wizard to recommend the proper version of XDebug which I downloaded and installed using the recommended php.ini and launch.json documentation. The path to my webroot is c:/RSense360/USB/UniServerZ/www and this is also the folder/project I have open in VS Studio

When I launch the debugger in VS Studio with “all breakpoints” selected it properly finds and stops on the various warnings and notices in my code when I run the script via my browser. VS Code loads the appropriate script and/or include as expected and lets me view all variables etc.

Also, if I manually add a break xdebug_break(); to the script VS Code stops on it as expected.

This would tell me that most of this is configured and working properly.

The problem is when I set a breakpoint in VS Code. In the example supported by the attached logs I set a column break at line 2 of script Metromain.php. This is right after the <?php tag. It is grey when set but turns red when I run the script (unverified to verified). Except - the script does not stop at the breakpoint. It continues on to normal completion.

When I look at the debug log all the paths appear correct.

I also tried another computer with a fresh install of a different WAMP stack and php 5.6 and had the same exact problem.

Help!

Chris


PHP version: 7.1 XDebug version: 2.5.4-7.1-vc14 Adapter version: 1.11.1


Your launch.json:
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 “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 } ] }


XDebug php.ini config:
[xdebug] zend_extension = C:\RSense360\USB\UniServerZ\core\php71\extensions\php_xdebug-2.5.4-7.1-vc14.dll xdebug.remote_autostart=on xdebug.remote_enable=on xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.idekey=default xdebug.remote_log=${US_ROOTF}/core/php71/logs/xdebug/xdebug.log


XDebug logfile (from setting xdebug.remote_log in php.ini):

xdebug.log

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 18 (2 by maintainers)

Most upvoted comments

I have solved my problem. Everything was configured properly. It was a matter of not understanding “where” to set breakpoints via VS Code. Breakpoints must be set on a line containing a php command. I was setting generic breaks on comment lines and blank lines. The debugger will not stop on these.

Also, if a command spans several lines (my example was an echo with multiple lines for visual clarity) the breakpoint must be set on the line with the terminating semicolon. Setting it on any other line within the command will cause it to be ignored.

This is probably all common knowledge but the debugger I use for other projects/technologies does not work this way.

eko3alpha - does this also solve your problem?

I was also having problems with the debugger and I could fix it by setting pathMappings and hostname.

// launch.json
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "hostname": "dev.local",
      "pathMappings": {
        "/var/www": "${workspaceFolder}"
      }
    },

If you are facing the same problem, I suggest you include "log": true in your launch.json, create a file with a single <?php phpinfo(); line and set a breakpoint there. Access the server and open the VS Code’s DEBUG CONSOLE to find out the path it’s sending, so you can setup the correct path.

@eko3alpha I’m thinking the problem should be solved instead of documenting how it doesn’t work properly.

I still have this issue, but i can always trigger a break by inserting some shitty code like dividing by zero. But having a hotkey to insert breaking code instead of just stopping at breakpoints is idiotic. I call them “breaking points” 😄

I was also having problems with the debugger and I could fix it by setting pathMappings and hostname.

// launch.json
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "hostname": "dev.local",
      "pathMappings": {
        "/var/www": "${workspaceFolder}"
      }
    },

If you are facing the same problem, I suggest you include "log": true in your launch.json, create a file with a single <?php phpinfo(); line and set a breakpoint there. Access the server and open the VS Code’s DEBUG CONSOLE to find out the path it’s sending, so you can setup the correct path.

This helped me after HOURS of trying to debug the debugger lol. All my breakpoints were becoming unverified and everything seemed correct. Setting "log":true showed me some useful info and could tell that my pathMappings were not correct. Thanks!

Thanks to @brunis for injecting bad code like ie echo 1/0; debugging in VS Code came alive.

But I had to add pathMapping to connect my (remote) files to the local due to Unable to open 'index.php': File not found (file:///var/www/html/web/index.php)

        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "pathMappings": {
                "/var/www/html": "/home/clemens/Documents/projects/docker4drupal"
            }
        },

i get the same message as @marciordonez and still can not manage to hit a breakpoint… can anybody help?

launch.json:

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

Thanks @holdech , that was the issue for me also, and I spent an inordinate amount of time trying to figure it out…

Like @eko3alpha, there is a slightly disparity between how you describe multi-line statements working and how they work for me, but either way I am glad to at least have a way to reliably break where I want to now, more or less. Agree with @brunis on a desire to see it fixed rather than just documented.