3

PHP debugging in vscode using xdebug and xampp is not working even after all configurations.

here is my php.ini file config:

zend_extension = D:\Xampp\php\ext\php_xdebug-3.0.0-7.3-vc15-x86_64.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

this is json file

{
    "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}"
        }

    ]
}

7 Answers 7

6

xDebug 3 has changed several default values, so be sure your code is ready to work with new ones.

Here is my configuration set, which allowed me to use PHP breakpoints as always:

.vscode\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
        }
    ]
}

php.ini (lines manually inserted in the end of a file)

    [xdebug]
    zend_extension = "php_xdebug-3.0.4.dll"
    xdebug.mode = debug
    xdebug.discover_client_host = 1
    xdebug.start_with_request = yes
    xdebug.client_port = 9000

Note: above zend_extension option would try to find your xdebug library in a .../modules/php/PHP_%your_php_version%/ext/ folder

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

2 Comments

+1 for the discover and start with request settings. Those did the job for me when VS Code was ignoring everything else
Note the port in both the vscode settings and the php.ini. The default changed from 9000 in xdebug 2 to 9003 in xdebug 3. So you either need to set them both to 9000 or change your settings to 9033 and leave php.ini silent.
5

I just got satisfaction with XDebug 3. I found a good response here :https://github.com/felixfbecker/vscode-php-debug/issues/411 by jason-nabooki. I do the same :

Json file :

    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "stopOnEntry": true,
            "log": true,
            "pathMappings": {"/var/wwww/ammac":"${workspaceRoot}"}
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9003
 

PHP.ini :

    xdebug.mode= debug
    xdebug.start_with_request = yes
    xdebug.discover_client_host = true

To use the debugger (I didn't find immediatly due to my precedent use of Eclipse !),

first : click on the green triangle near "Listen for XDebug

second : refresh the web page in Firefox (or other)

For me it works i got the variables. Not yet test the breakpoints.

Remark : no need of the XDEbug helper in Firefox (surprise!)

2 Comments

This works only because it is designed to stop at first line but it don't stop on breakpoints. If removed stopOnEntry it don't works at all anymore.
Suite: the problem is with the path mapping. ${workspaceroot} do not match "/var/www/ammac". Where is the "workspaceroot" ? To find it just do : File -> Open Folder : it shows you the workspace root, In my case :"/var/www". So I change "${worspaceRoot}" to "${workspaceRoot}/ammac" and it works definitively fine : F5 and it stops to breakpoint.
4

In VSCode, I went to Settings -> Features -> Debug -> Allow Breakpoints Everywhere.

I check marked "Allow Breakpoints Everywhere" and I was able to debug again.

Comments

0

Struggled with this myself. Apparently XDebug 3.x doesn't work as outlined above. I found that even the equates under [XDebug] are no longer compatible. Download XDebug 2.x (I think 2.98 is the latest in the 2.x series). After I switched to 2.x, I'm no longer having any issue (so far).

1 Comment

The default Xdebug port changed between Xdebug v2 to v3 from 9000 to 9003. Just change "port": 9000 => "port": 9003 in launch.json file when using XDebug 3.x ;-)
0

https://xdebug.org/wizard - This tool helped me to find the reason why debuger didn't work.

Comments

0

Your are using xdebug version 3:

zend_extension = ... php_xdebug-3....

but in configuration you listen port 9000:

"port": 9000

The default Xdebug port changed between Xdebug v2 to v3 from 9000 to 9003.

Just change "port": 9000 => "port": 9003

Comments

0
xdebug.discover_client_host = true
or
xdebug.client_host = "127.0.0.1"

is the key point for newer xdebug version

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.