Reputation: 51
I've been setting up XDebug for PHP on a remote VM, with PHPStorm as the IDE/client. I see a lot of questions about this on the site, but none about this situation...
I'm coding on a Windows machine, with PHPStorm synchronizing files automatically with my dev environment on a Linux VM. I have a tunnel on port 9001 from that VM back to my local machine. I'm trying to debug command line PHP scripts, and I've got this far:
Communication between my IDE and the XDebug instance seems to be fine, as I'm able to step through as long as it's from an xdebug_break() or the start of a script (though the IDE doesn't highlight the current line).
Looking at the xdebug.remote_log, I see the breakpoint being set on my local, Windows file instead of the path on the server - this seems like a problem...
<- breakpoint_set -i 7 -t line -f file://D:/git/php/php/tests/lookatme.php -n 8
(The double php/php is correct.)
If I trick it by symlinking a "/D:/git/php/php/" directory on my VM to the actual PHP directory and then run a PHP script, it actually works – but only if PHP is run from the root directory.
As far as I know, my mapping in Settings/PHP/Servers is correct - am I right in thinking that only the root folder of my PHP repository needs to be mapped to its equivalent on the remote server?
D:\git\php\php -> /company/mnt/codebase/DEVWEB/php/
My xdebug.ini:
xdebug.default_enable=0
xdebug.overload_var_dump=0
xdebug.profiler_enable_trigger=1
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name="cachegrind.out.%s.%t"
xdebug.remote_enable=On
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_port=9001
xdebug.remote_log=/tmp/xdebug.log
Scripts are run with the environment variable:
export XDEBUG_CONFIG="idekey=PHPSTORM"
Path mappings in PHPStorm:
https://i.sstatic.net/ItOYB.png
Thanks for any thoughts!
Upvotes: 1
Views: 513
Reputation: 51
Thanks for everyone's help and pointers - in the end it turned out I was missing an environment variable on my remote machine:
export PHP_IDE_CONFIG="serverName=RemotePHP"
where RemotePHP is the name of the server set up in Settings > PHP > Servers and selected in the debug configuration. Presumably, without this it didn't know how to map the incoming breakpoint to the right file.
Upvotes: 4
Reputation: 12592
I think you need to map every single file. It works for me with a remote server.
Upvotes: 0