Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xdebug V3 doesn't stop breakpoints in VSCode

I am trying to debug on my XAMPP using VSCode and didn't worked. I know there are tons of questions about this and I've tried everything I can but still won't work.

There is really 1 thing weird thou about my xdebug extension.I am currently using PHP v7.4.12 and Xdebug version 3.

I know my Xdebug works on PHP because I viewed phpinfo() and it shows just how I set it. The weird part is among the many of the tutorials out there normally zend_extension = path..,xdebug.remote_enable = 1 and xdebug.remote_autostart = 1 should be enough but when I viewed phpinfo it is as follows below:

enter image description here

I tried to set it with xdebug.remote_port = 9000 and xdebug.remote_host = "localhost" but still won't work. I even have read about changing localhost to 127.0.0.1 but still didn't work.

Any help would be appreciated. Here is my launch.json file and php ini file.

php.ini

zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.remote_port = 9000
xdebug.remote_host = "127.0.0.1"
xdebug.idekey=VSCODE

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": "Launch current script in console",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "externalConsole": false,
            "port": 9000
        },
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        }
    ]
}

If it is caused maybe due to not setting "pathMappings", anyone can teach me how to use this?

By the way the xdebug.log also doesn't work

like image 818
kenjiro jaucian Avatar asked Dec 04 '20 03:12

kenjiro jaucian


People also ask

How do you stop a breakpoint in VS code?

To set a breakpoint in source code: Click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

Why is Breakcode not hitting VSCode?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.


1 Answers

You are using Xdebug v3 but keep using Xdebug v2 config parameters. You need to go through Upgrading from Xdebug 2 to 3 Guide and adjust your settings.

Xdebug v3 uses different config params than Xdebug v2 (your phpinfo() output tells you exactly that on your screenshot). 5 out of 6 "xdebug." params from your current php.ini do nothing in Xdebug v3.

For Xdebug 3 it should be like this (based on your original config):

zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.client_host = "127.0.0.1"
xdebug.log = "C:\xampp\tmp\xdebug\xdebug.log"
xdebug.idekey = VSCODE
like image 175
LazyOne Avatar answered Sep 24 '22 01:09

LazyOne