Run on external console / Write to STDIN?

Hi,

I`m debugging my cli scripts with php-storm, but I have problem a when it comes to STDIN.
My scripts have some questions/answers at runtime, which the script reads from the STDIN and branches the execution.

readlineScript:

public static function readLine()
    {
        $text = "";
        do
        {
            $char = fread(STDIN, 1);
            $text .= $char;
        } while($char != "\n");
        return trim($text);
    }


Is it possible to write to the STDIN with phpstorm, or is it somehow possible to debug cli scripts on an external console?

0
4 comments

See http://stackoverflow.com/questions/5315247/debug-php-command-line-script-in-phpstorm for sample remote configuration.
As http://youtrack.jetbrains.net/issue/WI-5132 is addressed in 3.0, it should be easier in the next version.

Basic input should work in the console, but it's not a real terminal, so the functionality may be limited.

0

serge wrote:

See http://stackoverflow.com/questions/5315247/debug-php-command-line-script-in-phpstorm for sample remote configuration
As http://youtrack.jetbrains.net/issue/WI-5132 is addressed in 3.0, it should be easier in the next version.


I think the problems associated with these links are different than my question.
I have no problem debuging CLI scripts, yet it does work perfectly including startup parameters.

Basic input should work in the console, but it's not a real terminal, so the functionality may be limited.


The Console-Tab does show the script output, but unfortunately I can`t write anything into the console. Or is there a workaround for typing characters into the console?
As you can see in my attached screenshot, I need to send a simple "y" or "n" to my script in order to continue execution.



Attachment(s):
screenshot1.png
0

The link I sent you shows how to run a script in real terminal/console and have debugging. This should solve the problem if the input doesn't work in the built-in console.

0

Hello droth,

Please vote - http://youtrack.jetbrains.net/issue/WI-6093

Thank you for feedback!

0

Please sign in to leave a comment.