0

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 Kits8円.1\Windows Performance Toolkit\;
C:\Program Files\Microsoft SQL Server110円\Tools\Binn\;
C:\WINDOWS\System32\OpenSSH\;
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC170円\Tools\Binn\;
C:\Program Files (x86)\Microsoft SQL Server150円\Tools\Binn\;
C:\Program Files\Microsoft SQL Server150円\Tools\Binn\;
C:\Program Files\Microsoft SQL Server150円\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server150円\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');
asked Sep 9, 2022 at 13:15
14
  • What if you try php.exe instead? Commented Sep 9, 2022 at 13:24
  • the file name that I want to execute is child.php Commented Sep 9, 2022 at 13:58
  • And what does that have to do with replacing the command? Commented Sep 9, 2022 at 13:59
  • First I would try the full path. Commented Sep 9, 2022 at 14:02
  • sorry I thought you want me to change like proc_open("php php.exe") Commented Sep 9, 2022 at 14:05

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.