Skip to content

Instantly share code, notes, and snippets.



Created Feb 23, 2015
What would you like to do?
require_once __DIR__ . '/vendor/autoload.php';
use Symfony\Component\Process\ProcessBuilder;
// This doesn't work. The stream_select inside Process doesn't see any new
// input. We want to create a stream that can be written to asyncroniouly.
$inputStream = fopen("php://temp/", 'r+');
$processBuilder = new ProcessBuilder(array('cat'));
$process = $processBuilder->getProcess();
// Doesn't have to be fwrite.
fwrite($inputStream, "We have a winner!\n\n");
$exitCode = $process->wait();
$output = $process->getOutput();
if (empty($output)) {
echo "Sorry, no dice.\n\n";
} else {
echo $output;
"require": {
"php": ">=5.4.0",
"symfony/process": "~2.0"

This comment has been minimized.

Copy link

@gielfeldt gielfeldt commented Feb 24, 2015

It doesn't looke like Process and/or UnixPipes support proc_open() with a file resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment