2014-10-27 85 views
0

我添加的路徑變量和git正在完善的外殼/終端,但是當我嘗試XAMPP服務器上使用PHP的exec我得到這個錯誤的內部或外部命令,可操作的程序或批處理文件。「混帳」不被識別爲

'git' is not recognized as an internal or external command, operable program or batch file. 

我的PHP代碼是在這裏:

<?php 
    echo shell_exec("git pull https://github.com/Leadera/ecoman_repo.git 2>&1"); 
?> 

當我從CMD它的工作原理做的git拉的要求,但在瀏覽器中我得到一個錯誤。這是什麼問題?

問候, 金槍魚

回答

2

shell_exec搜索在XAMPP目錄git命令,你應該使用絕對路徑與git

<?php 
    echo shell_exec("/bin/git pull https://github.com/Leadera/ecoman_repo.git 2>&1"); 
?> 
0

亞歷山大的回答已經解決了這個問題,但我找到另一種方式來做到這一點。

我用

組PATH =%PATH%; C:\程序文件(x86)\ GIT中\ BIN (在視窗)

代碼來添加路徑XAMPP在XAMPP命令面板。 它也解決了我的問題。

+0

我以爲你在Linux上 – 2014-10-28 10:15:22

+0

C:\ Users \ xxx \ AppData \ Local \ GitHub \ PortableGit_c2ba306e536fdf878271f7fe636a147ff37326ad \ bin – Toolkit 2015-04-03 11:29:22