2014-04-01 48 views
2

我使用斯坦福命名空間,但其在斯坦福Tagger.php這個警告警告在斯坦福Tagger.php警告:proc_open():CreateProcess的失敗,錯誤代碼 - 0

警告:()proc_open:CreateProcess的失敗,錯誤代碼 - 0

它是造成這一行

$process = proc_open($cmd, $descriptorspec, $pipes, dirname($this->getJar())); 

我不知道如何解決它。

+0

我這裏有同樣的問題在我結束 –

+0

有什麼在$這必須是一個絕對目錄路徑,或 NULL CMD? –

+0

請查看http://readlist.com/lists/lists.php.net/php-windows/0/798.html –

回答

0

我看過php documentation中的例子,我也遇到了同樣的錯誤(我在使用WAMP的窗口中)。

一些周圍挖掘後,我發現我可以解決省略了目錄和env PARAMS的問題,例如 - 這對我的作品:

<?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"; 
} 

?> 

所以,你可以嘗試更新您的代碼:

$process = proc_open($cmd, $descriptorspec, $pipes, dirname($this->getJar())); 

要:

$process = proc_open($cmd, $descriptorspec, $pipes); 

如果這對你有用,那麼問題出在你的代碼的這一行dirname($this->getJar())。這個路徑不存在或者它不可訪問。

你做了var_dump()dirname($this->getJar())並檢查路徑是否存在?


上面的例子是固定通過設置當前工作目錄這樣也:

$process = proc_open('php', $descriptorspec, $pipes, getcwd(), $env); 

根據文檔:

CWD

該命令的初始工作DIR 。如果你想使用默認值(當前PHP程序的工作目錄)