tags:

views:

151

answers:

2

Hi everyone,

I am setting up a github account, to work on a small project with some friends. I would like to have my home machine able to do a git pull via php, so that we just have to call this small php file for the machine to be up to date.

As of right now :

<?php
$output = shell_exec('git help');
echo "<pre>$output</pre>";
?>

This works perfectly and I get the output, I am in the right directory, so git pull should work just as well, but I get a hanging page, no error, nothing.

Any idea ?

EDIT : A few precisions, the repo is pretty small, around 300K, it takes only a few seconds from the command line. I also tried shell_exec("dir"), and I am in the right directory. I am running the default installation of xampp on Windows 7 x64, if I can be precise enough :)

+1  A: 

I suggest exploring set_time_limit() , as well as making sure your git pull does not stop if the user disconnects via ignore_user_abort(). Even running from a gigabit connected server, some repositories just take a while to clone.

Also, check PHP's working directory, and ensure the user running PHP has privileges to write to the repo. If you ran this via CLI and it 'just works', its a good chance that PHP was running without appropriate privileges when accessed via whatever web server you are using.

If you chmod the destionation directory as 777 and it works, there's a very good chance that you need to recompile apache/php for suexec support. Please, don't just leave it as 777 if that is the case :)

Either way, time out and user aborts are still valid considerations, even after you get it working.

Tim Post
The thing is, from the command line, the command takes a mere second, the repository is very small. And even if I let it run for a few minutes, nothing.The working directory is the right one as the php script is called from the root directory of the project. (I also tried shell_exec dir, just to be sure).
rnaud
@maud: updated my answer
Tim Post
I'm running under Windows, so no chmod. But the question of privileges is a good one, I'll look it up.I'll add time limit and ignore user abort as soon as I've got it working :)
rnaud
+1  A: 

So, to answer my own question.

It was in fact a permission problem (thanks tim), from the PHP CLI, the script was working.

The problem was that the service php installation is using some strange permissions. So you/I need to start the PHP server via the command line (or in this case the Xampp control panel).

Now it's working, giving me the "Already up-to-date." answer I was waiting for :)

rnaud