xref: /php-uv/examples/spawn.php (revision 99312394)
1<?php
2
3$in  = uv_pipe_init(uv_default_loop(), true);
4$out = uv_pipe_init(uv_default_loop(), true);
5
6echo "HELLO ";
7
8$stdio = array();
9$stdio[] = uv_stdio_new($in, UV::CREATE_PIPE | UV::READABLE_PIPE);
10$stdio[] = uv_stdio_new($out, UV::CREATE_PIPE | UV::WRITABLE_PIPE);
11
12$flags = 0;
13uv_spawn(uv_default_loop(), "php", array('-r','var_dump($_ENV);'), $stdio, "/usr/bin/",
14    array("KEY"=>"hello"),
15    function($process, $stat, $signal){
16	    uv_close($process,function(){});
17
18}, $flags);
19
20uv_read_start($out, function($out, $buffer){
21    echo $buffer;
22
23    uv_close($out,function(){});
24});
25
26uv_run();
27