array("pipe"" /> array("pipe"" /> array("pipe""/>

proc_open() function returns 'PHP' is not recognized

424 views Asked by At

I am using Wamp I want to get output from the file opened with proc_open()

$cwd=null;
$description = array(
    0 => array("pipe", "r"),
    1 => array("pipe", "w"),
    2 => array("file", "error-output.txt", "a") );

$process = proc_open("php child.php", $description, $pipes, $cwd);
    fclose($pipes[0]);
    echo stream_get_contents($pipes[1]);
    fclose($pipes[1]);
    $return_value = proc_close($process);
    echo "command returned $return_value\n";

but it returns 'PHP' is not recognized as an internal or external command in error-output.txt enter image description here

I have already included the path in environment variables and I can execute the command in CMD or VsCode terminal

enter image description here

I have added the path in system variables System Variable picture here

But running the command print_r(getenv('PATH')) in the child.php printed the following

C:\Program Files (x86)\Common Files\Oracle\Java\javapath;
C:\WINDOWS\system32;
C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;
C:\Program Files (x86)\Microsoft SQL Server\150\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;
C:\Program Files\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;
C:\Program Files\Azure Data Studio\bin;
E:\Softwares\NodeJs\;
C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps

So I don't know why the PHP path is not listed here and I also don't know how to give path explicitly in the argument of proc_open() as it accept an array for $env as official documentation says

$env = array('some_option' => 'aeiou');
0

There are 0 answers