0

First, I'm very new to PHP. I'm trying to use the PHP Debug extension in VS Code with PHP Version 8.0.2 and Xdebug Version 3.0.2.

I've switched the Apache ports to 9000/90001. Everything seems to work correctly in the browser when I navigate to localhost:9000/test.php. However, when I try to debug in VS Code, the breakpoints are never triggered.

My PHP.ini Xdebug section:

[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-3.0.2-8.0-vs16-x86_64.dll"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.idekey = VSCODE
xdebug.remote_host=127.0.0.1
xdebug.default_enable=1

xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
xdebug.remote_handler = "dbgp"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.trace_output_dir = "c:\xampp\tmp"
xdebug.remote_cookie_expire_time = 36000

My 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 currently open script",
            "type": "php",
            "request": "launch",
            "program": "",
            "cwd": "",
            "port": 9000
        },
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        }
    ]
}

Any help here would be greatly appreciated!

LazyOne
  • 158,824
  • 45
  • 388
  • 391
CB589
  • 23
  • 4
  • 1
    1) Apache port has NOTHING to do with Xdebug port. Xdebug port has to be DIFFERENT to the web server port. It's Xdebug that connects to debug client (VSCode in your case) and NOT other way around. https://learnxdebug.com/ 2) Do NOT mix Xdebug v2 and Xdebug v3 config params. Most of the Xdebug v2 params do NOTHING in v3.https://xdebug.org/docs/upgrade_guide – LazyOne Feb 11 '21 at 20:49
  • 1
    Just find a guide on how to make Xdebug working in VSCode and stick to it -- try not to "mix and match" info from different sources at once. Here is an Xdebug config that should work for you: https://stackoverflow.com/a/65141934/783119 . Make sure that Apache listens on some standard port (e.g. `80` or `8080` etc and NOT `9000`). **P.S.** Xdebug v3 uses 9003 as a default port. So just user that number in Xdebug config and your launch.json. – LazyOne Feb 11 '21 at 20:54

1 Answers1

0

Your configuration contains mixed statements from different XDebug versions (v2.x and v3), while your XDebug extension looks to be v3. Please take a look at the following guide to understand which configuration should belongs to v3:

https://xdebug.org/docs/upgrade_guide

I have succeeded with this config using v3:

xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host=192.168.1.3
xdebug.client_port=9000
xdebug.log=/tmp/xdebug.log
Tarcisio Júnior
  • 1,097
  • 1
  • 13
  • 25