Hi there. I am a complete newbie with php and vscode and xdebug. I put in my localSourceRoot and ServerRoot but the Intellisense tells me that it is deprecated and to use pathMappings instead.
I have no idea what information to put in the places requested. Please explain what each term is in pathMappings.
This is what I've got so far, but I don't know what the first "/app/public" is supposed to be.
"pathMappings": {
"/app/public": "${workspaceRoot}c:/wamp64/www/wp_new/wordpress"
I've read other discussions/posts and even have been exhausting my efforts with google but still have no idea what I am doing.
}
PHP version: 7.1.9
XDebug version: 2.6.0.6
Adapter version: What adapter?
Your launch.json: {
// 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,
"pathMappings": {
"/app/public": "${workspaceRoot}c:/wamp64/www/wp_new/wordpress"
}
//"/path/on/server": "${workspaceRoot}/local/path"
//"localSourceRoot": "C:/wamp64/www/wp_new/wordpress",
// "serverSourceRoot": "C:/wamp64/www/wp_new/wordpress"
}
]
}
XDebug php.ini config: ; XDEBUG Extension
[xdebug]
; zend_extension ="c:/wamp64/bin/php/php7.1.9/zend_ext/php_xdebug-2.5.5-7.0-vc14-x86_64.dll"
zend_extension="c:/wamp64/bin/php/php7.1.9/zend_ext/php_xdebug-2.6.0-7.1-vc14-nts-x86_64.dll"
xdebug.remote_enable = on
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = Off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="c:/wamp64/tmp"
xdebug.remote_port = 9000
xdebug.remote_host = localhost
xdebug.show_local_vars=0
XDebug logfile (from setting xdebug.remote_log in php.ini):
Adapter logfile (from setting "log": true in launch.json):
Code snippet to reproduce:
I think you should try removing the pathMappings property altogether, because it is only neccessary if you are trying to debug a _remote_ php process, but since you're using Wamp, it's a _local_ php process. If you are trying to debug PHP on a remote server or if you're running php through virtualization, like VirtualBox, or a container, i.e. Docker, then pathMappings is neccessary. In your case, using Wamp, it will only make the debugger listen for the wrong thing.
Also read up on this if you want to use linting (which I very much recommend): https://code.visualstudio.com/docs/languages/php
Thank you, kajes, I can only hope this fixes the problem I'm having.
I think explanation of what these are supposed to be would be helpful. You have a set of Key value pairs where everything is a variable and nothing is obvious. I am using this remote and cannot make heads or tails of what I am supposed to set these to or how the tool would even have access to know these paths in the remote server. What do they map to? I get that workspaceroot is effectively a pwd for the workspace.
This was all working for me until recently. Have no idea how to even debug xdebug but it just doesn't work. Nothing changed in config and now I'm seeing that this is marked as deprecated:
"localSourceRoot": "${workspaceFolder}/public",
It says to use pathMappings instead but what's supposed to go on the left? Here are a few I've seen referenced but I'm not sure which is right cause none of them work:
/
/var/www
/var/www/public
/app
/public
public
What IS the server path and how do I find it? I'm starting a local php server for ZF2 like so:
php -S 0:8888 -t public public/index.php
It says to use pathMappings instead but what's supposed to go on the left?
@intellix the left side is the path on your remote I guess. Honestly I personally not sure if my answer is correct, since I fairly new to this extension. But in my case I'm using WSL and it works that way.
Let say, from Windows side my project is located in d:\path\to\project and from WSL side we'll see it located in /mnt/d/path/to/project so I set my pathMappings like this
"pathMappings": {
"/mnt/d/path/to/project/app": "${workspaceRoot}/app"
}
and it works.
Hope that help. Cheers 🥂
I'm new to VS.Code but have done a lot of PHP debugging elsewhere. I think there might be some terminology confusion here related to workspaces, since I ran into a similar headache setting this up. This is what I figured out.
To use the above example, assume that the path to a given file to debug on the server is /mnt/d/path/to/project/app/index.php, and that in the current workspace in VS.Code, you've added the local folder app. I would have expected to set pathMappings as
"pathMappings": {
"/mnt/d/path/to/project/app": "${workspaceRoot}/app"
},
but you actually should set it as
"pathMappings": {
"/mnt/d/path/to/project/app": "${workspaceRoot}"
},
Thank you, Rolf, for helping. I will look into it the next time I open VSCode.
Thanks again.
In your debt,
Eric Hoff
From: Rolf Kaiser notifications@github.com
Sent: Friday, November 2, 2018 12:21 PM
To: felixfbecker/vscode-php-debug vscode-php-debug@noreply.github.com
Cc: eghoff1 blackforestboy00@outlook.com; Author author@noreply.github.com
Subject: Re: [felixfbecker/vscode-php-debug] Newbie: please explain pathMappings (#254)
I'm new to VS.Code but have done a lot of PHP debugging elsewhere. I think there might be some terminology confusion here related to workspaces, since I ran into a similar headache setting this up. This is what I figured out.
To use the above example, assume that the path to a given file to debug on the server is /mnt/d/path/to/project/app/index.php, and that in the current workspace in VS.Code, you've added the local folder app. I would have expected to set pathMappings as
"pathMappings": {
"/mnt/d/path/to/project/app": "${workspaceRoot}/app"
},
but you actually should set it as
"pathMappings": {
"/mnt/d/path/to/project/app": "${workspaceRoot}"
},
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/felixfbecker/vscode-php-debug/issues/254#issuecomment-435464684, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AhnYilsC3O6rCz-U-NeDmP_fC3cAfnSMks5urJsMgaJpZM4TCEm8.
I'm new to VS.Code but have done a lot of PHP debugging elsewhere. I think there might be some terminology confusion here related to workspaces, since I ran into a similar headache setting this up. This is what I figured out.
To use the above example, assume that the path to a given file to debug on the server is
/mnt/d/path/to/project/app/index.php, and that in the current workspace in VS.Code, you've added the local folderapp. I would have expected to setpathMappingsas"pathMappings": { "/mnt/d/path/to/project/app": "${workspaceRoot}/app" },but you actually should set it as
"pathMappings": { "/mnt/d/path/to/project/app": "${workspaceRoot}" },
Wow. Found this after one hour trying to get xdebug to work.
Felix, I suggest you could myabe update/clarify the extension description in vscode ?
Many thanks for your great work!
Hi, I have trouble with proper mapping. I'm on Mac currently and since docker for mac has poor performance (I haven't been able to set it up to be smooth as it can be on Linux etc.) I'm using vagrant and then inside vagrant I have docker installed. Using devilbox http://devilbox.org/.
I know that the mappings for the devilbox would be this:
"pathMappings": {
"/shared/httpd/arktisCH/htdocs": "${workspaceFolder}/htdocs"
}
But I have additional layer of mapping needed as vagrant has its own mapping and has this setup:
config.vm.synced_folder './public', '/vagrant-nfs', type: "nfs",
config.bindfs.bind_folder "/vagrant-nfs", "/home/vagrant/docker"
I'm doing additional biding because of the NFS turned on and vagrant extension is being used there to make that happen and working.
Now I'm not sure even if its possible to activate the xDebug with this setup at all? Any help appriciated.
If anyone else is crying about pathmappings in vs code, this solved it for me:
I tried everyhing, this did not work:
"pathMappings": {
"\\my_remote_file_share\\my_root": "${fileDirname}"
}
This did work:
"pathMappings": {
"/my_remote_file_share/my_root": "${fileDirname}"
}
So even though I was running php locally on a _Windows_ machine, it required that I use forward slashes. Only forward slashes would work.
My full config looks like this:
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"runtimeExecutable": "C:\\PHP\\php.exe",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9003,
"pathMappings": {
"/my_remote_file_share/my_root": "${fileDirname}"
}
}
I'm running the files locally so I don't see why I need to map any paths, nothing is being compiled or built or transpiled or moved, the stack trace even shows exactly where the files are when an error occurs, so it makes no sense that they would be mangled...
Anyways, happy coding, or whatever I guess...
Most helpful comment
I'm new to VS.Code but have done a lot of PHP debugging elsewhere. I think there might be some terminology confusion here related to workspaces, since I ran into a similar headache setting this up. This is what I figured out.
To use the above example, assume that the path to a given file to debug on the server is
/mnt/d/path/to/project/app/index.php, and that in the current workspace in VS.Code, you've added the local folderapp. I would have expected to setpathMappingsasbut you actually should set it as