如何使用PHP管道rake输出?

I'm building a RAKEFILE and I want to display the output on a php generated page as it gets executed.

I tried using system() since the PHP docs mention this:

The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module.

This seems to work with multiple shell comands but when I execute rake I only get the first line:

(in /Users/path/to/proj)

Any ideas?

Cheers!

The system() call also tries to automatically flush the web server's output buffer after > each line of output if PHP is running as a server module.

This means you would only get the last line of output from the return value. The example in the system() manual page shows that and it suggests to use passthru() to get raw output. I usually use exec() though.

Try use exec() function

   exec($command, $output); 

$output is an array

//retrieved data
for($out = '',$x = 0,$len = count($output); $x < $len; $x++) {
      $out .= $output[$x] . "
";
}

or simple:

$out = join("
", $output); 

Turs out both functions system() & exec() actually work. The generated rake output when using --verbose isn't taken into consideration though. That's why I was confused. If anyone has more extensive knowledge on the distinction, do share :)