2017 © Pedro Peláez
 

library gihp

Git SCM access through PHP

image

vierbergenlars/gihp

Git SCM access through PHP

  • Sunday, September 22, 2013
  • by vierbergenlars
  • Repository
  • 3 Watchers
  • 4 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

gihp -- Git in PHP

Build Status, (*1)

Gihp is a set of classes to work with git repositories in pure PHP. Not a single line of shell code is executed., (*2)

Recently a full-history rewrite was executed https://gist.github.com/vierbergenlars/5191906, (*3)

Installation

Add vierbergenlars/gihp to your composer.json or run composer.phar require vierbergenlars/gihp, (*4)

{
    "require": {
        "vierbergenlars/gihp": "*"
    }
}

API documentation

Only the API documentation for the latest version is available online. Earlier versions can be generated from source with ApiGen, (*5)

Basic usage

Opening a repository and getting basic information is a piece of cake., (*6)

<?php

use gihp\Repository;
use gihp\IO\File;

$io = new File('.');
$repo = new Repository($io); // Load the repository that lives in the working directory

$branches = $repo->getBranches(); // Loads all branches in the repository

echo "Branches in this repo: \n";
foreach($branches as $name=>$branch) {
    // Branches have their name as key, and a gihp\Branch object as value.
    echo $name."\n";
}


$tags = $repo->getTags(); // Loads all tags in the repository
echo "Tags in this repo: \n";

foreach($tags as $name=>$tag) {
    echo $name."\n";
}

But what if you want to learn more about a tag?, (*7)

<?php

// ...

$tag = $repo->getTag('v0.1.0'); // Load the tag "v0.1.0", returns gihp\Tag

echo "About the 0.1.0 version: \n";

$tag->getName(); //returns "v0.1.0", obviously.

// Gihp automatically determines the type of the tag.
// When it is an annotated tag, functions are called on that annotated tag.
// When it's a normal tag, functions are called on the commit it refers to.

echo 'Message: '.$tag->getMessage()."\n"; // Gets the message associated with the tag.
echo 'Created by: '.$tag->getAuthor().' on '.$tag->getDate()."\n"; // Gets the person associated with the tag.
echo 'Commit '.$tag->getCommit()->getSHA1()."\n"; // But this will surely always fetch the commit object to act upon.

Doing stuff with branches also is perfectly fine, (*8)

<?php

// ...

$branch = $repo->getBranch('master'); // Load the master branch, returns gihp\Branch

echo "About the master branch: \n";

$branch->getName(); // "master"

echo 'Last commit by:'.$branch->getHeadCommit()->getAuthor()."\n";

$tree = $branch->getTree(); // A gihp\Tree

echo 'Contents of readme.md:'."\n".$tree->getFile('readme.md');

The Versions

22/09 2013

dev-master

9999999-dev

Git SCM access through PHP

  Sources   Download

MIT

The Development Requires

by Lars Vierbergen

17/02 2013

v0.10.0

0.10.0.0

Git SCM access through PHP

  Sources   Download

MIT

The Development Requires

by Lars Vierbergen

12/02 2013

v0.9.1

0.9.1.0

Git SCM access through PHP

  Sources   Download

MIT

The Development Requires

by Lars Vierbergen

16/01 2013

v0.9.0

0.9.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

15/01 2013

v0.8.0

0.8.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

15/01 2013

v0.7.0

0.7.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

05/12 2012

v0.6.0

0.6.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

04/12 2012

v0.5.0

0.5.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

04/12 2012

v0.4.1

0.4.1.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

02/12 2012

v0.4.0

0.4.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

27/11 2012

v0.3.0

0.3.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

23/11 2012

v0.2.0

0.2.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen

22/11 2012

v0.1.0

0.1.0.0

Git SCM access through PHP

  Sources   Download

MIT

by Lars Vierbergen