Why are not all paths properly mapped when running a PHP script via SSH?
My development setup consists of a Windows PC with a Linux virtual machine that runs PHP. PHPStorm connects via SSH to the VM and executes scripts. Lately I noticed an odd thing - only SOME paths are mapped when a script is run. For example:
Let's say I keep my project at "C:\Projects\foo" and in my VM "C:\Projects" is mapped as "/bar". Now let's suppose I run a PHP script via RUN/Debug configurations. In addition I want to pass in a path to a config file as a parameter. What I see in the debug window is:
"[sshConfig://user@localhost:2222 password]:/usr/bin/php" /bar/foo/magic.php -c C:/Projects/foo/magic_config.json
Notice that it correctly mapped "magic.php" to its location in the virtual machine. However in the parameter, the config file is still referenced by its Windows file name. If I take a look at the .run.xml file I see:
<configuration path="$PROJECT_DIR$/magic.php" scriptParameters="-c $PROJECT_DIR$/magic_config.js">
This looks like it should be correct, but the end result is obviously not. I tried other variables in place of $PROJECT_DIR$, but none worked.
Is this by design or is this a bug? Is there a way to work around it?
Note: I could just hardcode the full path to the configfile without any variables, however then I cannot share my .run.xml with other colleagues who have different setups.
请先登录再写评论。
Unfortunately, PhpStorm is not so smart to parse and automatically convert paths in the Run configuration "Arguments" section. At the moment, there is no workaround that I may think of and suggest now, sorry.
I see. Oh well. My colleague did however come up with a nice workaround - just use relative paths. Don't know why I didn't think of that. :D Although it might not work for everyone, so keeping fingers crossed that one day PHPStorm will be smart enough. :)