Run configuration as different user?
PHPStorm 107.224, OSX 10.6.7.
I have a situation where I'd like to execute and debug a command line script, but I need to run it as a different user than PHPStorm is running. From the command line, I can simply run this:
sudo -u theuserinquestion php myphpscript.php
I've been through the edit configuration and I see lots of space for script options, but nothing that can change the command line to sudo. Is there a facility for changing the command line my php interpreter is called with?
Please sign in to leave a comment.
Hi Andrew,
You may be able to achieved this with the help of External Tools (sorry, I'm on Windows so cannot verify this for you).
1) File | Settings | External Tools
2) Create new entry there:
a) sudo will go into"Program" field
b) -u theuserinquestion php myphpscript.php into "Parameters" field. You can replace specific script name by one of the built-in Macro so that you can use such External Tool for specific/currently active file.
3) Test it .. and if happy you can assign specific keyboard shortcut in "Settings | Keymap" if required
Kind of related thread: http://devnet.jetbrains.net/thread/304984
Hello Andrew,
Please describe your case. Probably you can get the same effect using some of PhpStorm features. Otherwise, please create a new feature request - http://youtrack.jetbrains.net/issues/WI#newissue=yes.
Thank you for feedback!
Andrew,
Do you still have the issue?
Thank you for feedback!
Well, sort of. I was able to configure the external tools menu to run the script as expected, once I discovered it on the tools menu. I actually expected it to be on the run drop-down. However, when it runs, the environment is not correct, and the script fails because of that. I may be able to hack that together, and I will keep trying.
In the process of doing this, I realized that my ultimate goal is to be able to debug the script that's running via the external tools. Is there a way to do that? I don't see a method for running the tool in debug mode.
Hello Andrew,
We made some improvements in this area in upcoming PhpStorm 3.0(see - http://youtrack.jetbrains.net/issue/WI-5132), but it is also possible in PhpStorm 2.1.2.
First of all you need to create a new 'PHP Remote Debug' run configuration with empty fake server.
Fake server:
'PHP Remote Debug' run configuration:
Execute run configuration and set breakpoint:
Actiave debug session. There are two possible ways:
1) via environment variable XDEBUG_CONFIG:
XDEBUG_CONFIG="idekey=Nikolay.Matveev"
see - http://xdebug.org/docs/remote#starting
2) via configuration options:
since 'xdebug.remote_autostart' is enabled, xdebug will try to connect to debug server(PhpStorm, any other ide) on every request
http://xdebug.org/docs/remote#remote_autostart
Run your tool and stop at breakpoints
Thank you for feedback!
Thank you! The next time I have a few minutes, I'll implement your suggestion.