有没有人成功地让 PHPshell_exec()成功运行 Cordova-CLI 命令?本质上,当我运行以下命令时:
<?php
try {
putenv('PATH='. getenv('PATH') .':/usr/local/bin');
exec('cordova -v 2>&1', $output);
print_r($output);
}
catch(Exception $ex) {
echo '<pre>';
print_r($ex);
}
?>
Run Code Online (Sandbox Code Playgroud)
我得到以下结果:
Array
(
[0] => path.js:8
[1] => throw new TypeError('Path must be a string. Received ' +
[2] => ^
[3] =>
[4] => TypeError: Path must be a string. Received undefined
[5] => at assertPath (path.js:8:11)
[6] => at Object.posix.join (path.js:479:5)
[7] => at Object.<anonymous> (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:35:31)
[8] => at Module._compile (module.js:410:26)
[9] …Run Code Online (Sandbox Code Playgroud)