I was wondering if it's possible to map more than one path in vscode?
I'm working with Vagrant to develop a WordPress theme, and I'm using two shared folders on the guest.
I'm sharing one folder for the root of WordPress installation called www and the other one which is in the same path called main, shared on the guest within themes folder of WordPress installation.
Vagrantfile:
config.vm.synced_folder "./www/", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
config.vm.synced_folder "./main", "/var/www/wp-content/themes/main", :mount_options => ["dmode=777", "fmode=666"]
The problem is with the current launch.json file I'm not able to define two paths for my source codes, and when I'm debugging, VSCode doesn't hit the breakpoints anywhere in the main folder!
Take a look at the hierarchy below:

It's worth mentioning I'm currently achieving this using Sublime Text, but I'd like to work in VSCode instead.
Sublime Text project settings:
{
"settings": {
"xdebug": {
"path_mapping": {
"/var/www/wp-content/themes/main" : "/Users/[user]/Documents/[project]/main",
"/var/www" : "/Users/[user]/Documents/[project]/www",
},
"super_globals": true,
"close_on_stop": true
}
}
}
Extra info:
PHP version: 5.6.14-1
XDebug version: 2.3.3
Your launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"serverSourceRoot": "/var/www",
"localSourceRoot": "/Users/[user]/Documents/[project]/www"
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
Thanks in advance.
Amin
That path_mapping API looks nice. Feel free to do a PR 🙂
Feel free to do a PR
What's PR, what do you mean?
A Pull Request. I currently don't have much time to spend on this project and wouldn't use this feature myself. But you can fork the repository, add the feature and then open a Pull Request which I will merge in.
The source mapping is done here: https://github.com/felixfbecker/vscode-php-debug/blob/master/src/paths.ts
You could change the signature to accept a path map instead of localSourceRoot and serverSourceRoot. Then add the launch.json setting in package.json and the LaunchArguments interface. When calling the functions, put localSourceRoot and serverSourceRoot into the path mapping object for backwards compatibility.
+1
Please don't +1 issues. It clutters the thread without adding value to the discussion and spams maintainers with notifications. Use GitHub reactions to upvote features.

I have a feeling that it makes more sense to map $local_folder: $vm_source because there is a guarantee that a local folder cannot be mapped to multiple locations within the VM, whereas multiple local folders could potentially be mapped to a single location within the VM. Does that make sense?
... Not that I see the use case, but I see it being a possibility.
Added a PR for this issue, also in regards to my above comment, I went with the original suggested server => local configuration
This feature would also help massively for concrete5 (https://www.concrete5.org/) CMS development. Concrete5 uses complex symfony2 routing, which makes stepping through code impossible with only a single URL:path mapping.
I note that VS Debugger for Firefox (https://marketplace.visualstudio.com/items?itemName=hbenl.vscode-firefox-debug) supports an array of pathMappings.
I think you are confusing application/web routing with local/server path mapping
You could well be right. Concrete5 claims to have routing, and the path used to render a page can vary (eg, to over-ride a default layout template or core class behaviour).
In a concrete5 project, I can use vscode-php-debug to debug some code (eg, stepping, breakpoints and exceptions), but not other code on the same locally-hosted site. This suggests that the localSourceRoot and serverSourceRoot are set correctly for some of the code, and that something else is going on.
I accept that this is a low priority and of no use to you, but here's some more info: https://documentation.concrete5.org/tutorials/override-almost-any-core-file-in-5-7
I can provide more links (but no knowledge).
ETA: Ignore me. For some reason, deleting both ...SourceRoot settings allows all debug features to work in all files; when I set those values, debugging would only work on SOME pages. Don't ask me why.
In case you are wondering what a valid use-case scenario for this is (at least for me), I am attempting to standardize a containerized workflow. If you are developing a PHP CLI project which is independent of and performs actions on a secondary PHP project (e.g., a website), but loads the entirety of both projects such that /bin/cli-project and /var/www/html both need mappings in order to detect an error in either project, you quickly hit a wall with this extension. I think the lack of this functionality currently puts VS Code at a distinct disadvantage for developing applications like wp-cli and composer, when other editors support this functionality. Maybe containers will fizzle out, but it is my opinion that most projects will begin to standardize a contribution environment based on containers, as they provide an easy way to provision and modify an exact server environment. So for me, this issue is such a priority that I dove into typescript for the first time and contributed a PR :)
We have the same Problem here, but with a different Use Case: We're using PHP's "auto_prepend_file" to work around a nasty and longstanding bug in PHP related to Syslog Logging. The File is outside of the Web-Root, even outside the Project, but readable/accessible.
This would be handy in cases where using docker to run tests and the different docker environments have different root folders for the path mappings. Currently, you can only have one path mapping or you have to use a completely separate debug configuration, which can be annoying.
I left a comment on the wrong issue, I don't mind having a look at this as I'd rather not use atom.
Same issue for me that I can't use Docker volume mappings to a php docker container to map themes and plugins from different local root paths.
However I'd like a bit of help from a dev to ask a few questions (gitter?) as it's a fairly large code base I've never seen before till now :)
I've had a look through and see a couple of areas that might need changed but really it's just a map of local to remote paths that need a getter to search and return.
Actually there is a PR open for this, #175. I never found the time to test it, but if you could check it out and tell me if it works for you, we could merge it in.
@felixfbecker thanks, I should have found myself. I'll have a look how to test
@felixfbecker I want to try it but I can't seem to package this extension. Forgive me if I missed something, as this is the first time I'm trying to build an extension.
$ yarn && yarn build && yarn vsce package
yarn install v1.3.2
[1/5] 🔍 Validating package.json...
warning [email protected]: The engine "vscode" appears to be invalid.
[2/5] 🔍 Resolving packages...
success Already up-to-date.
✨ Done in 0.37s.
yarn run v1.3.2
$ tsc -p .
✨ Done in 4.07s.
yarn run v1.3.2
$ /Users/Documents/vscode-php-debug/node_modules/.bin/vsce package
Error: The specified icon 'extension/images/logo.png' wasn't found in the extension.
error Command failed with exit code 1.
Should work now on master.
@felixfbecker His PR works :heart::heart::heart:
Most helpful comment
@felixfbecker His PR works :heart::heart::heart: