Created
May 20, 2012 17:57
-
-
Save MattKetmo/2758928 to your computer and use it in GitHub Desktop.
StreamedProcessResponse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\HttpFoundation\StreamedResponse; | |
use Symfony\Component\Process\Process; | |
class StreamedProcessResponse extends StreamedResponse | |
{ | |
public function __construct(Process $process, $status = 200, $headers = array()) | |
{ | |
$callback = function() use ($process) { | |
$process->run(function ($type, $buffer) { | |
echo $buffer; | |
flush(); | |
}); | |
}; | |
parent::__construct($callback, $status, $headers); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment