# xDebug with VS Code

**URL:** https://discourse.roots.io/t/xdebug-with-vs-code/28930
**Category:** trellis
**Tags:** lima
**Created:** 2024-11-21T16:53:53Z
**Posts:** 3

## Post 1 by @visualasparagus — 2024-11-21T16:53:53Z

I just wanted to document my settings here for getting xDebug to run in Visual Studio Code with Lima (on OSX)

I’m running xDebug version 3.x.x

For my launch.json I have the following config block for “Listen for debug”

```
"name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "stopOnEntry": true,
            "port": 9003,
            "pathMappings": {
                "/srv/www/projectname.com/current": "${workspaceFolder}/site"
            }
        }
```

`"stopOnEntry":` can also be set to `false` depending on what you want. I sent it to `true` to just initially test it was working but then turned it to `false`.

Then I need to align the ide\_key of vscode to that of my browser plugin which is the xDebug Chrome Extension ([https://chromewebstore.google.com/detail/xdebug-chrome-extension/oiofkammbajfehgpleginfomeppgnglk](https://chromewebstore.google.com/detail/xdebug-chrome-extension/oiofkammbajfehgpleginfomeppgnglk))

You can find the value VSCode is expecting in this settings variable `php.debug.idekey` and for me it is set to `vsc`. You then need to update this in the Chrome extension settings to match. Mine was originally set to `PHPSTORM`.

Once this is all done, activate “Debug” mode in the Chrome extension, start the debugger and reload the page in the browser.

I hope this is useful to someone.

---

## Post 2 by @visualasparagus — 2024-11-22T12:46:02Z

i noticed one improvement regarding the path mappings it should not include the `web` directory. The main post has been corrected.

---

## Post 3 by @mZoo — 2025-10-03T13:39:06Z

Thanks for taking the time to share this @visualasparagus.

If the `.vscode/launch.json` file is in the `site` directory path mapping is `"/srv/www/example.com/current": "${workspaceFolder}"`, without “site”.

As I’m working mostly on a smaller segment of the codebase (a plugin) I may experiment with having multiple `launch.json` files with differing paths so that I have fewer files for VS Code to manage.
