• This repository has been archived on 01/Oct/2021
  • Stars
    star
    164
  • Rank 230,032 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 14 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

NOT MAINTAINED - Provide an object oriented wrapper to run any Git command. For PHP 5.2 and 5.3.

PHP Git Repo

Manage a Git repository with PHP. Provide an object oriented wrapper to run any Git command.

Requirements

  • PHP >= 5.2 (PHP 5.3 works fine)
  • Git >= 1.5

Instantiate a PHPGit_Repository

$repo = new PHPGit_Repository('/path/to/the/git/repo');

It does NOT create a Git repo, but a PHP object to manipulate an existing Git repo.

Create a Git repository

If the Git repository does not exist yet on filesystem, PHPGit_Repository can create it for you.

$repo = PHPGit_Repository::create('/path/to/the/git/repo');

It runs git init and returns a PHPGit_Repository object.

Run git commands

git commands can be run with the same syntax as in the CLI. Some examples:

// change current branch to master
$repo->git('checkout master');

// pull from a remote
$repo->git('pull origin master');

// add a remote repo
$repo->git('remote add origin git://github.com/ornicar/php-git-repo.git');

There is no limitation, you can run any git command.

The git() method returns the output string:

echo $repo->git('log --oneline');

e30b70b Move test repo to system tmp dir, introduce PHPGit_Command
01fabb1 Add test repo
12a95e6 Add base class with basic unit test
58e7769 Fix readme
c14c9ec Initial commit

The git() method throws a GitRuntimeException if the command is invalid:

$repo->git('wtf'); // this git command does NOT exist: throw GitRuntimeException

Get branches informations

Some shortcut methods are provided to deal with branches in a convenient way.

Get the branches list:

$branches = $repo->getBranches();
// returns array('master', 'other_branch')

Get the current branch:

$branch = $repo->getCurrentBranch();
// returns 'master'

Know if the repo has a given branch:

$hasBranch = $repo->hasBranch('master');
// returns true

Get tags informations

Get the tags list:

$tags = $repo->getTags();
// returns array('first_release', 'v2')

Get commits informations

You can get an array of the last commits on the current branch.

$commits = $repo->getCommits(15);
// returns an array of the 15 last commits

Internally, this methods run git log with formatted output. The return value should look like:

Array
(
    [0] => Array
        (
            [id] => affb0e84a11b4180b0fa0e5d36bdac73584f0d71
            [tree] => 4b825dc642cb6eb9a060e54bf8d69288fbee4904
            [author] => Array
                (
                    [name] => ornicar
                    [email] => [email protected]
                )

            [authored_date] => 2010-09-22 19:17:35 +0200
            [commiter] => Array
                (
                    [name] => ornicar
                    [email] => [email protected]
                )

            [committed_date] => 2010-09-22 19:17:35 +0200
            [message] => My commit message
        )

    [1] => Array
        (
            ...

The first commit is the more recent one.

Debug mode

PHPGit_Repository constructor second parameter lets you enable debug mode. When debug mode is on, commands and their output are displayed.

$repo = new PHPGit_Repository('/path/to/the/git/repo', true);

Configure

PHPGit_Repository can be configured by passing an array of options to the constructor third parameter.

Change git executable path

You may need to provide the path to the git executable.

$repo = new PHPGit_Repository('/path/to/the/git/repo', false, array('git_executable' => '/usr/bin/git'));

On most Unix system, it's /usr/bin/git. On Windows, it may be C:\Program Files\Git\bin.

Change the command class

By default, PHPGit_Repository will use PHPGit_Command class to implement Git commands. By replacing this option, you can use your own command implementation:

$repo = new PHPGit_Repository('/path/to/the/git/repo', false, array('command_class' => 'myGitCommand'));

Run test suite

All code is fully unit tested. To run tests on your server, from a CLI, run

php /path/to/php-git-repo/prove.php

More Repositories

1

php-github-api

NOT MAINTAINED - Development moved to github.com/KnpLabs/php-github-api
PHP
322
star
2

lichess-old

DEPRECATED - see http://github.com/ornicar/lila
PHP
252
star
3

dotfiles

My beloved Linux dot files for zsh, tmux, git, tig, vim, mpd, mutt, rtorrent, weechat, xmonad, urxvt, vimperator, ranger...
Shell
192
star
4

vindinium

Artificial Intelligence Challenge - scala game server
JavaScript
169
star
5

php-user-agent

NOT MAINTAINED - Browser detection in PHP5. Uses a simple and fast algorithm to recognize major browsers.
PHP
148
star
6

lichess-puzzler

Python
99
star
7

ApcBundle

UNMAINTAINED - Use https://github.com/Smart-Core/AcceleratorCacheBundle instead
PHP
92
star
8

scalex

[abandoned] Hoogle-like documentation search engine, for scala
Scala
90
star
9

vindinium-starter-python

Python starter bot for Vindinium
Python
36
star
10

OrnicarAkismetBundle

Akismet.com integration for your Symfony2 application
PHP
30
star
11

php-html-writer

Write HTML tags with CSS expressions
PHP
21
star
12

FOQTyperBundle

Generate PHP classes from YAML templates
PHP
19
star
13

pgn4web

Git mirror of http://code.google.com/p/pgn4web/
PHP
17
star
14

zulip-remind

Zulip bot that posts messages in a stream at a fixed date.
TypeScript
16
star
15

ltc

French website built on Symfony2
PHP
15
star
16

scalariver

scalariform server to format scala faster
HTML
14
star
17

ZendPaginatorAdapter

Provides Zend Paginator Adapters. Currently Doctrine MongoDB and Doctrine ORM pagers are implemented.
PHP
12
star
18

diem-project

Diem Project official website
PHP
12
star
19

vindinium-starter-clojure

Clojure starter bot for Vindinium
Clojure
12
star
20

userstyles

My collection of user styles, since userstyles.org is down
CSS
12
star
21

vindinium-starter-scala

Scala starter bot for Vindinium
Scala
10
star
22

lichess-puzzle-kit

10
star
23

scalex-web

Simple JS client to Scalex JSON API
JavaScript
10
star
24

lichess-layout

CSS
9
star
25

chesshq.com-front

Source code for the frontend of chesshq.com
TypeScript
9
star
26

dmWidgetGalleryPlugin

Adds a Gallery widget to the Add menu
JavaScript
8
star
27

scala-elasticsearch

Elasticsearch client for scala [EDIT] You may want to check that one instead: https://github.com/bsadeh/scalastic
Scala
7
star
28

OrnicarInsaneMarkdownBundle

DEPRECATED - Use PHPSkirt instead https://github.com/chobie/phpskirt
PHP
6
star
29

scala-paginator

Generic paginator for scala
Scala
6
star
30

fide-pgn-viewer

Source code of the page https://worldrapidandblitz.fide.com/open-rapid/, provided by FIDE under the GPL license.
TypeScript
5
star
31

dmContactPlugin

Display a contact form on the site, manage entries on admin
PHP
5
star
32

scala-aichallenge

My take on aichallenge.org in scala
Scala
5
star
33

furet

Music database written in scala
Scala
5
star
34

backdoor

HTTP command line backdoor using scala/play-2.1
Scala
5
star
35

passport-lichess

GitHub authentication strategy for Lichess and Node.js.
JavaScript
5
star
36

dmChessPlugin

Multiplayer and artificial intelligence Chess game
PHP
5
star
37

lichess-game-migration

Scala
4
star
38

clojure-kit

Clojure kit for prismic.io
Clojure
4
star
39

chessify-frontend

Source code of the chessify.me frontend
JavaScript
4
star
40

muteZatShit

Let's kick web radio ads in the teeth
JavaScript
4
star
41

dmFlowPlayerPlugin

Allows to read video, sound and flash medias
JavaScript
4
star
42

dmSqlBackupPlugin

Creates SQL backups of your project
PHP
4
star
43

vim-php-debugger

Vim & xdebug debugger proted from http://www.vim.org/scripts/script.php?script_id=1929
Python
4
star
44

dmCkEditorPlugin

Adds a CkEditor WYSIWYG to your site
JavaScript
4
star
45

diem-talk

Website using dmTalkPlugin to provide a web chat
PHP
4
star
46

nixos-config

Just my personal Nix config
Nix
4
star
47

haichess.com

Mirror of the haichess.com source code. I do not maintain this repo. It's a copy of https://gitee.com/baidaye/lila
Scala
3
star
48

pgn-recorder

Fetches and stores PGN from a URL every second.
JavaScript
3
star
49

lantenora

Photo gallery made with Diem 5.1
PHP
3
star
50

jdubext

Wrapper and extensions for jdub
Scala
3
star
51

dmCommentPlugin

Allows to add comments to your records.
PHP
3
star
52

wolfie

Vindinium Scala AI
Scala
3
star
53

app.chesslang.com

All source code courtesy of chesslang.com
TypeScript
3
star
54

dmWidgetTwitterPlugin

Display tweets in a front widget
PHP
3
star
55

stream-voice

My voice on https://www.twitch.tv/ornicar2/
JavaScript
3
star
56

zulip-lichess

Multi-purpose Zulip bot for the Lichess workspace
TypeScript
3
star
57

worldchess-frontend

Front-end source code for https://worldchess.com and https://arena.myfide.net/, under the GPL-v3 license. Contact [email protected] to get the latest version of this source code.
TypeScript
3
star
58

lichess-mongo-import

import tournaments and stuff from prod mongodb
TypeScript
2
star
59

dmGoogleMapPlugin

Easily display configurable google maps
PHP
2
star
60

dmGithubPlugin

Provides php-github-api and some front widgets
PHP
2
star
61

sf2playground

A dumb Symfony2 project configured with mongodb+mysql to try out bundles
PHP
2
star
62

dmTalkPlugin

HTML+CSS+JS chat without registration
PHP
2
star
63

nestor

Hostel management webapp using event sourcing
Scala
2
star
64

mongoPHP

mongoPHP is a simple PHP based MongoDB administration tool based on the GAS Framework. It is completely open source and maintained by Simon Fletcher (http://twitter.com/simonify).
PHP
2
star
65

wwc

World War Chess
JavaScript
2
star
66

conx

scala learning project: cli connectX game with decent AI
Scala
2
star
67

dmBotPlugin

Browses your website, detects errors and preloads the cache
PHP
2
star
68

ape-petition

A complex web application based on Diem 5.1. Buzz & social petitions for a french environmental association.
PHP
2
star
69

ornicar.github.com

HTML
2
star
70

sltc

JavaScript
2
star
71

muteZatShit-old

Ad blocker for web radios - take that, ads!
JavaScript
2
star
72

vim-mru

Plugin to manage Most Recently Used (MRU) files
Vim Script
2
star
73

lichess-gmail

Extra gmail features to better help lichess users
JavaScript
2
star
74

github-actions-graph

TypeScript
2
star
75

vim-dirdo

[Git mirror] Performs Vim commands over files recursively under multiple directories.
Vim Script
2
star
76

http-pgn-split

Split big PGN sources into multiple URLs, for use with lichess broadcasts
JavaScript
2
star
77

dmWidgetFeedReaderPlugin

Displays RSS and Atom feeds on your site
PHP
2
star
78

lichess-crowdin

OCaml
1
star
79

dmWidgetExternalVideoPlugin

Provides widgets to embed videos from youtube, dailymotion and vimeo
1
star
80

clojure-starter

Clojure starter kit for prismic.io
Clojure
1
star
81

lichess-search-import

Scala
1
star
82

zen-catacomb

Connected foosball cave
Scala
1
star
83

clife-step1

Clojure
1
star
84

play-cdi-leak

Demo classloader leak in playframework dev run
Scala
1
star
85

munin-lichess

PHP
1
star
86

dmOppPlugin

Observatoire Photographique du Paysage
PHP
1
star
87

lichess-data

1
star
88

play-run-mem

Scala
1
star
89

s2test

Scala
1
star
90

mixit-lichess

JavaScript
1
star
91

lila-jmh-benchmarks

Java
1
star
92

tsp

Yet Another TSP Solution
C++
1
star
93

kcacup

Scala
1
star
94

dmCoreTranslatorPlugin

Helps writing Diem translations
PHP
1
star
95

hacksquare

HTML
1
star
96

sf2minimal

Minimal sf2 project. Trying to determine whether or not SF2 is testable under Windows
PHP
1
star
97

haskant

Ants artificial intelligence written in Haskell
Haskell
1
star
98

idbase

Playframework / MongoDB advanced search
Scala
1
star
99

scalabug

scalabug
Scala
1
star
100

praxeum

Scala
1
star