Create a gist now

Instantly share code, notes, and snippets.

bug?
<?php
$p = new Phar('test.phar', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME);
$p->startBuffering();
$stub = <<<STR
#!/usr/bin/env php
<?php
Phar::mapPhar();
include "phar://test.phar/parent.php";
__HALT_COMPILER();
STR;
$p->setStub($stub);
$parent = <<<STR
<?php
\$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
);
\$path = realpath(__DIR__ . '/child.php');
\$process = proc_open('php ' . \$path, \$descriptorspec, \$pipes);
if (is_resource(\$process)) {
fclose(\$pipes[0]);
\$stdout = stream_get_contents(\$pipes[1]);
fclose(\$pipes[1]);
fclose(\$pipes[2]);
\$return_value = proc_close(\$process);
var_dump(\$stdout);
var_dump(\$return_value);
}
STR;
$p['parent.php'] = $parent;
$child = <<<STR
<?php
file_put_contents(sys_get_temp_dir() . '/child', "child");
echo "child";
STR;
$p['child.php'] = $child;
$p->stopBuffering();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment