I'm using Stanford namespace But having this warning in Stanford Tagger.php
Warning: proc_open(): CreateProcess failed, error code - 0
it's caused by this line
$process = proc_open($cmd, $descriptorspec, $pipes, dirname($this->getJar()));
I can't know how to resolve it.
I had a look at the example in the php documentation and I was getting the exact same error as well (I am on windows using WAMP).
After some digging around, I found that I can fix the problem by omitting out the dir and env params, for example - this works for me:
<?php
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "error-output.txt", "a") // stderr is a file to write to
);
$cwd = 'D:/wamp/www/test';
$env = array('some_option' => 'aeiou');
$process = proc_open('php', $descriptorspec, $pipes, /* $cwd, $env */ );
if (is_resource($process)) {
// $pipes now looks like this:
// 0 => writeable handle connected to child stdin
// 1 => readable handle connected to child stdout
// Any error output will be appended to /tmp/error-output.txt
fwrite($pipes[0], '<?php print_r($_ENV); ?>');
fclose($pipes[0]);
echo stream_get_contents($pipes[1]);
fclose($pipes[1]);
// It is important that you close any pipes before calling
// proc_close in order to avoid a deadlock
$return_value = proc_close($process);
echo "command returned $return_value\n";
}
?>
So, can you try updating your code from:
$process = proc_open($cmd, $descriptorspec, $pipes, dirname($this->getJar()));
To:
$process = proc_open($cmd, $descriptorspec, $pipes);
If this works for you, then the problem is with this line dirname($this->getJar()) of your code. Either this path does not exists or the it's not accessible.
Have you do a var_dump() of dirname($this->getJar()) and check if that path exists?
The above example was fixed by setting current working dir like this also:
$process = proc_open('php', $descriptorspec, $pipes, getcwd(), $env );
According to documentation:
cwd
The initial working dir for the command. This must be an absolute directory path, or NULL if you want to use the default value (the working dir of the current PHP process)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With