0

I'm trying to set up Xdebug to work in VSCode on a Windows environment with a Lighthouse / Laravel based server. My VSCode settings look like this

{
    // 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": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },

        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

I've also tried adding a pathMappings to there with no luck

"pathMappings": {
            "/graphql": "${workspaceRoot}/public"
        }

I've followed https://laracasts.com/series/visual-studio-code-for-php-developers/episodes/13 and added all there suggested configurations. When I type php -v

PHP 7.4.10 (cli) (built: Sep  1 2020 16:52:21) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v3.0.0, Copyright (c) 2002-2020, by Derick Rethans

I do see Xdebug installed. My php.ini looks like this

[XDebug]
zend_extension = "php_xdebug-3.0.0-7.4-vc15-nts-x86_64.dll"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_host=localhost
xdebug.idekey=VSCODE
xdebug.remote_log ="C:\tools\xdebug.log"

Any advice would be greatly appreciated

  • Use Xdebug 3 config parameters -- they are DIFFERENT to what Xdebug 2 is using (that you have in your php.ini). Check the upgrade docs and alter your config: https://xdebug.org/docs/upgrade_guide – LazyOne Dec 02 '20 at 11:31
  • Thanks that solved it for me. I didn't realise everything I was reading was out of date should of read the docs more thoroughly thanks for your help. – Julian Mourell Dec 02 '20 at 12:07
  • Xdebug 3 was released about 1 weeks ago only. Almost all tutorials will be out of date in this regard (unless author watched for and took care of that, which is rare), it just not that many ppl would expect such changes in config params and simplyfy the config. These changes were needed: they clear up some misunderstandings (not that many ppl actually read the docs to see what the option does -- they simply copy-paste without thinking and follow try-and-error approach) – LazyOne Dec 02 '20 at 12:19

1 Answers1

0

For anyone else with a similar problem just needed to upgrade my php.ini.

[XDebug]
zend_extension = "php_xdebug-3.0.0-7.4-vc15-nts-x86_64.dll"
xdebug.mode = debug
xdebug.start_with_request=yes
xdebug.idekey=VSCODE

Ended up something like this not even sure if the idekey is even necessary now. That and change the port to 9003 as that changed in version 3 apparently.

  • Yes, the default port has been changed from `9000` to `9003` as it often conflicts (on Lunux & Mac) with php-fpm that also uses that port. You can tell Xdebug to use whatever port you want (`xdebug.client_port`), even original 9000. – LazyOne Dec 02 '20 at 12:14