title: How to show a remote git log using PHP
body: <p>I have created a website which is being hosted by one.com and is being used for a school project. I would like to show certain information (retrieved by the git log command) to our visitors. For this I have tried using PHP and the following script(also found <a href="https://gist.github.com/latheesan-k/3490cb6ab522ca87f535" rel="nofollow">here</a>):</p>
  
  <pre><code>&lt;?php
  // Author: Ngo Minh Nam
  $dir = "azureuser@drone7.cloudapp.net:/home/azureuser/git/drones/";
  $output = array();
  chdir($dir);
  exec("git log",$output);
  $history = array();
  foreach($output as $line){
      if(strpos($line, 'commit')===0){
          if(!empty($commit)){
              array_push($history, $commit);  
              unset($commit);
          }
          $commit['hash']   = substr($line, strlen('commit'));
      }
      else if(strpos($line, 'Author')===0){
      $commit['author'] = substr($line, strlen('Author:'));
      }
      else if(strpos($line, 'Date')===0){
      $commit['date']   = substr($line, strlen('Date:'));
      }
      else{       
      $commit['message']  .= $line;
      }
  }
  
  print_r($history);
  
  ?&gt;
  </code></pre>
  
  <p>According to the users that used the script it should work. Personally I believe that the problem, in our case, resides in the fact that one.com is hosting our website and Git is being hosted on a remote server that has been created by someone else in our project team and should be accessible by: azureuser@drone7.cloudapp.net:/home/azureuser/git/drones/</p>
  
  <p>This results into the fact that chdir will only be able to find folders located in the hierarchy of our website.</p>
  
  <p>Does anyone know how we can solve this problem and will be able to show information from the git log (from a remote server) on our website?</p>