# Trellis + Xdebug + Vscode - local development

**URL:** https://discourse.roots.io/t/trellis-xdebug-vscode-local-development/11087
**Category:** trellis
**Created:** 2017-12-07T20:59:06Z
**Posts:** 5

## Post 1 by @lane — 2017-12-07T20:59:06Z

I’ve had a hell of a time getting xdebug working locally with vscode, but now that I have, I thought I’d share.

installed this: [https://github.com/felixfbecker/vscode-php-debug](https://github.com/felixfbecker/vscode-php-debug)  
ansible-version: 2.4.2.0  
using chrome for debugging, and I did not install any chrome extensions

my launch.json config:

```
{
"version": "0.2.0",
"configurations": [{
 "name": "Listen for XDebug",
 "type": "php",
 "request": "launch",
 "pathMappings": {
     "/srv/www/example.com/current/web/app": "${workspaceRoot}/site/web/app"
   },
   "port": 9000
  }]
}
```

[example.com](http://example.com) is the site name you are using. (you might be using something like [http://example.dev](http://example.dev) or [http://example.test](http://example.test), but your site name would be [example.com](http://example.com))

I’m running this launch.json from the root of my project (ie the folder that contains trellis and bedrock)

first run `vagrant up` then run the debugger, throw in a breakpoint, then navigate to [http://example.dev?XDEBUG\_SESSION\_START=XDEBUG\_ECLIPSE](http://example.dev?XDEBUG_SESSION_START=XDEBUG_ECLIPSE)

Hope this helps someone.

---

## Post 2 by @d-a-v-e — 2018-04-24T17:16:32Z

Hi @lane thanks so much for this. I have debugging set up thanks to you.

is `workspaceRoot` a Vscode variable?

Also, can you shed some light on the last step - visiting that url? I hadn’t realised this was needed after every vagrant up! **(to anyone referencing this - if debugging has mysteriously stopped working, be sure to redo that last step!!)**

---

## Post 3 by @adambrgmn — 2018-09-27T06:07:30Z

Getting into this conversation a little late, but…

Thanks for your clarifications about setting up the debugging in VS Code! But I felt a bit annoyed with the need of using the `?XDEBUG_SESSION_START=XDEBUG_ECLIPSE`-bit.

So I found out that by adding `xdebug_remote_autostart: 1` to `trellis/group_vars/development/php.yml` and then running `vagrant reload --provision` the debug session starts automagically.  
Just a tip (and maybe you, @d-a-v-e, are interested in this).

And yes @d-a-v-e `workspaceRoot` is a [VS Code variable](https://code.visualstudio.com/docs/editor/debugging).

---

## Post 4 by @d-a-v-e — 2018-10-07T20:08:21Z

thanks for the tip @adambrgmn. This doesn’t auto start xdebug in production does it?

---

## Post 5 by @adambrgmn — 2018-10-15T12:44:55Z

No it wont :slight_smile:
