Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created January 28, 2018 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/ef6dd977649eb2857ba832f0e9e1d5d6 to your computer and use it in GitHub Desktop.
Save zoffixznet/ef6dd977649eb2857ba832f0e9e1d5d6 to your computer and use it in GitHub Desktop.
<?php
$com = 'perl6 -e \'use JSON::Fast; slurp.&from-json.reverse».uc.&to-json.put\'';
$data = ["foo", "bar", "ber", 42];
$process = proc_open(
$com, [0 => ["pipe", "r"], 1 => ["pipe", "w"]],
$pipes, '.', NULL
);
if (is_resource($process)) {
fwrite($pipes[0], json_encode($data));
fclose($pipes[0]);
echo "Got answer: " . stream_get_contents($pipes[1]);
fclose($pipes[1]);
$return_value = proc_close($process);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment