Search code examples
phpvisual-studio-codeinstallationxamppxdebug

VSCode with Xdebug doesn't stop at breakpoint


I have a beginners question. I am fighting to get Xdebug to run for PHP in Visual Studio Code. I tried a lot, but nothing seems to work. VSCode doesn't stop at my breakpoints. Here is a list of things I already have tried or setup:

  • I edited the PHP.ini from the Apache server in XAMPP. As you can see I added the dll already:
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.idekey="vscode"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.remote_port = "8066"
zend_extension = C:\xampp\php\ext\php_xdebug-3.0.3-8.0-vs16-x86_64.dll
  • Made sure the Apache server listens to the 8066 port.
  • In Visual Studio Code I installed PHP debug and other PHP intellisence stuff
  • the launch.json in VSCcode is as followed:
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 8066,
"runtimeExecutable": "C:/xampp/php/php.exe"

"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 8066,
"runtimeExecutable": "C:/xampp/php/php.exe"
  • I also set php.exe as a standard in VSCode:

screenshot vs code php settings

What am I doing wrong? I bet it is something very stupid. I hope some of you guys have some advice.


Solution

  • I fixed my problem as followed:

    1. I set the Apache server to another port that is not: 9000 or 9003

    2. After reading the link i understood that a lot of settings where V2. So i changed the xdebug setting to only:

      xdebug.remote_autostart = yes
      xdebug.mode = debug
      zend_extension = C:\xampp\php\ext\php_xdebug-3.0.3-8.0-vs16-x86_64.dll
      

    https://xdebug.org/docs/upgrade_guide

    1. in visual studio code I changed the launch.json port to 9003 (which is the default port in Xdebug)

    It worked perfectly! Thank you LazyOne!