1

Guess this theme repeated here 1000 times, but I didn't find why VSCode cannot debug PHP code.

  • Latest VSCode with all required PHP extensions (PHP Debug also). Windows 11.
  • php --version:
PHP 8.3.9 (cli) (built: Jul  2 2024 18:17:57) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.9, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.9, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
  • xdebug section in php.ini is:
[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.log_level = 0
  • VSCode launch.json:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        }
    ]
}
  • netstat -tan | grep 9003:
  TCP    0.0.0.0:9003           0.0.0.0:0              LISTENING       InHost
  TCP    127.0.0.1:57536        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57537        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57538        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57541        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57542        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57543        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57544        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57546        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    127.0.0.1:57547        127.0.0.1:9003         TIME_WAIT       InHost
  TCP    [::]:9003              [::]:0                 LISTENING       InHost
  • Start Laravel Development Server, put debug breakpoint in right place, then open page in Firefox (with Xdebug helper set in "Debug" mode) - nothing debugged, just ordinal execution.
1
  • 1
    1) Get rid of xdebug.log_level = 0 (by default it would be level 7) 2) Enable Xdebug log, start your debug and try to debug. Then check the Xdebug log and see what it has to say -- if it tries to connect at all and what the response is. 3) netstat -tan | grep 9003 -- that's nice... but which app/process is actually listening on that port? Make sure it's VSCode (run the same when VSCode is closed, maybe you have some other app already on that port) Commented Sep 22, 2024 at 10:56

0

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.