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?

6 comments
Comment actions Permalink

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

0
Comment actions Permalink

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!

0
Comment actions Permalink

Andrew,

Do you still have the issue?

Thank you for feedback!

0
Comment actions Permalink

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.  

0
Comment actions Permalink

Hello Andrew,

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?


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:
fake_server.png

'PHP Remote Debug' run configuration:
remote_debug_run_configuration.png

Execute run configuration and set breakpoint:

execute_remote_debug_run_configuration.png

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
via_configuraion_options.png

Run your tool and stop at breakpoints

stop_at_breakpoint.png

Thank you for feedback!

0
Comment actions Permalink

Thank you!  The next time I have a few minutes, I'll implement your suggestion.

0

Please sign in to leave a comment.