在 PHP 中从 EXEC 运行“git pull”


Running a 'git pull' from EXEC in PHP

我正在尝试在运行XAmpp的Windows上使用PHP的exec从git运行拉取请求。当使用 execsystem 运行下面的脚本并尝试访问文件时,页面永远不会停止加载。我已经检查了目录的文件权限,它们都是 0777。和运行git status运行良好。不知道问题是什么。

<?php
ignore_user_abort(true);
set_time_limit(15);
exec('git pull origin master', $o);
echo implode("'n", $o);
?>

更新帐户上没有密码:

C:'xampp'htdocs>git pull origin master
From github.com:************
 * branch            master     -> FETCH_HEAD
Already up-to-date.
C:'xampp'htdocs>

从终端运行 i 得到:

C:'xampp'htdocs>php -f update.php
PHP Warning:  PHP Startup: ming: Unable to initialize module
Module compiled with build ID=API20090626,TS,VC6
PHP    compiled with build ID=API20090626,TS,VC9
These options need to match
 in Unknown on line 0
Warning: PHP Startup: ming: Unable to initialize module
Module compiled with build ID=API20090626,TS,VC6
PHP    compiled with build ID=API20090626,TS,VC9
These options need to match
 in Unknown on line 0
From github.com:*********
 * branch            master     -> FETCH_HEAD
Already up-to-date.
C:'xampp'htdocs>
不要使用

exec ,它会等到过程完成,而是使用 passthru 并确保禁用了输出缓冲。这样,您将立即看到问题所在。