Challenge
<?php | |
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')); | |
$processBuilder->setInput($inputStream); | |
$process = $processBuilder->getProcess(); | |
$process->start(); | |
// Doesn't have to be fwrite. | |
fwrite($inputStream, "We have a winner!\n\n"); | |
fclose($inputStream); | |
$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" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
It doesn't looke like Process and/or UnixPipes support proc_open() with a file resource.