2017 © Pedro Peláez
 

library git4p

A native PHP git library

image

git4p/git4p

A native PHP git library

  • Thursday, April 7, 2016
  • by mvdkleijn
  • Repository
  • 3 Watchers
  • 25 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 5 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

Status: No longer active / archived, (*1)

Build Status Codacy Badge Codacy Badge StyleCI, (*2)

Git4P

"Git4P" stands for "Git for PHP" and is a native PHP Git library that can access a Git repository without using external help like the standard git commands. It is geared towards server side (bare) repositories., (*3)

Please let me know how you're using this library., (*4)

Examples

Create a new bare repository

Git::init('/tmp/mytestrepo');

Add a simple blob

In this example the blob is 'orphaned', which means it is unreachable through any commits., (*5)

$git = Git::init('/tmp/mytestrepo');

$readme = "GIT4P\n=====\n\nThis is a simple test repo for git4p.\n";

$blob = new GitBlob($git);
$blob->setData($readme)
     ->store();

Full basic repository with a single commit

We programmatically create a blob (file), a tree (directory) that points to it and then a commit pointing to the tree. Finally we make sure the master branch points to this commit., (*6)

$git = Git::init('/tmp/mytestrepo');

$readme = "GIT4P\n=====\n\nThis is a simple test repo for git4p.\n";
$user = new GitUser();
$user->setName('Some User')
     ->setEmail('some.user@example.com')
     ->setTimestamp('1374058686')
     ->setOffset('+0200');

$blob = new GitBlob($git);
$blob->setData($readme)
     ->store();

$arr = ['README.md' => $b];
$tree = new GitTree($git);
$tree->setData($arr)
     ->store();

$commit = new GitCommit($git);
$commit->setTree($tree->sha())
       ->setMessage('Initial commit.')
       ->addAuthor($user)
       ->addCommiter($user)
       ->store();

$git->updateBranch('master', $commit->sha());

Note

This library currently has limited pack support. Reading in and listing packed refs is supported through GitRef but support for packed objects is not implemented yet., (*7)

Some TODOs

  • Add pack support
  • Add proper phpdoc blocks

The Versions

07/04 2016

dev-master

9999999-dev

A native PHP git library

  Sources   Download

MIT

The Requires

  • php ^5.4

 

The Development Requires

by Martijn

repository git php native

12/08 2015

dev-develop

dev-develop

A native PHP git library

  Sources   Download

MIT

The Requires

  • php ^5.4

 

The Development Requires

by Martijn

repository git php native

02/08 2015

v0.0.1-alpha

0.0.1.0-alpha

A native PHP git library

  Sources   Download

MIT

The Requires

  • php ^5.4

 

The Development Requires

by Martijn

repository git php native