YiiGit 36

A git wrapper for Yii, allows access to all git commands programatically

phpnode/YiiGit

Written in PHP by 6 contributors

Contribute

Need Support?


we offer maintenance, support and development services for all our open source projects.

Contact Us

Introduction

A Yii wrapper for the git command line executable. Allows access to all git commands via a simple object oriented interface.

Usage examples

Add some files and folders to git

$repository = new AGitRepository("path/to/your/git/repo");
$repository->add("somefile.txt");
$repository->add("somedirectory");

Commit some files with git

$repository->commit("Added some files");

Checkout an existing branch

$repository->checkout("some-existing-branch");
echo $repository->activeBranch->name; // some-existing-branch

Checkout a new branch

$repository->checkout("some-new-branch", true);
echo $repository->activeBranch->name; // some-new-branch

List all branches

foreach($repository->branches as $branch) {
    echo $branch->name."\n";
}

List all tags with metadata

foreach($repository->tags as $tag) {
    echo $tag->name"\n";
    echo $tag->authorName"\n";
    echo $tag->authorEmail"\n";
    echo $tag->message"\n";
}

List all the commits on the current branch

foreach($repository->activeBranch->commits as $commit) {
    echo $commit->authorName." at ".$commit->time."\n";
    echo $commit->message."\n";
    echo str_repeat("-",50)."\n";
}

List all the files affected by the latest commit

foreach($repository->activeBranch->latestCommit->files as $file) {
    echo $file."\n";
}

Check if a tag exists on the default remote ('origin')

$repository->remote->hasTag('myTag');

List all branches on a remote repository called 'upstream'

foreach($repository->getRemote('upstream')->getBranches() as $branch) {
    echo $branch."\n";
}

API

AGitRepository

setPath($path, $createIfEmpty = false, $initialize = false)
getPath()
run($command)
add($file)
rm($file, $force = false)
commit($message = null, $addFiles = false, $amend = false)
status()
describe($options = '')
checkout($branchName, $create = false, $force = false)
clean($deleteDirectories = false, $force = false)
cloneTo($targetDirectory)
cloneFrom($targetDirectory)
cloneRemote($sourceUrl)
push($remote, $branch = "master", $force = false)
fetch($repository)
getActiveBranch()
getBranches()
hasBranch($branch)
createBranch($branchName)
deleteBranch($branchName, $force = false)
getCommit($hash)
getTags()
getTag($name)
hasTag($tag)
addTag($name, $message, $hash = null)
removeTag($tag)
getRemotes()
getRemote($remote = null)
hasCommit($hash)

AGitCommit

getAuthorName()
getAuthorEmail()
getTime()
getSubject()
getMessage()
getNotes()
getParents()
getFiles()

AGitBranch

getCommits()
getCommit($hash)
getLastCommit()

AGitTag

push($remote = null)
getAuthorName()
getAuthorEmail()
getMessage()
getCommit()

AGitRemote

getBranches()
hasBranch($branch)
deleteBranch($branchName)
getTags()
hasTag($tag)




43 other PHP projects


phpwkhtmltopdfPHP 716

A slim PHP wrapper around wkhtmltopdf with an easy to use and clean OOP interface

php-pdftkPHP 213

A PDF conversion and form utility based on pdftk

yii2-localeurlsPHP 189

Automatic locale/language management for URLs

YiiRedisPHP 131

A set of wrappers for different data types in redis

yiipasswordPHP 81

Password strategies for Yii

yii2-dockerizedPHP 64

A template for docker based Yii 2 applications

YiiSolrPHP 50

A wrapper for the pecl solr library that provides common Yii constructs, such as models, data providers etc

php-shellcommandPHP 48

A simple object oriented interface to execute shell commands in PHP

Yii-Docs-GeneratorPHP 47

Generates HTML documentation for Yii applications

YiiElasticSearchPHP 32

Elastic Search client for Yii

YiiCurlPHP 30

A curl library for Yii

YiiStateMachinePHP 28

A state machine behavior for Yii

yii2-streamlogPHP 19

A Yii 2 log target for streams in URL format

oauth2yiiPHP 18

An OAuth2 client / server extension for the Yii framework

packagecompressorPHP 16

A Javascript/CSS compressor based on Yii's package system

restyiiPHP 16

A RESTful extension for Yii.

localeurlsPHP 12

Automatic locale/language management for URLs

php-excel-readerPHP 12

It reads the binary format of XLS files directly and can return values and formats from any cell. This project is the fork of http://code.google.com/p/php-excel-reader/ that, apparently, is no longer maintained.

pdfablePHP 10

A Yii extension to create PDFs with PHPWkHtmlToPdf/wkhtmltopdf

yii-api-vimPHP 8

Yii API manual plugin for VIM

yii2-excel-messagePHP 7

Translate messages via Excel files

yii2-bs3activeformPHP 7

A Bootstrap 3 enhanced ActiveForm for Yii 2

xcrudcontrollerPHP 7

A base class to quickly build customized CRUD interfaces.

handlebarsphpPHP 6

Transpiles handlebars templates into native PHP templates

Yii-Package-ManagerPHP 6

A package manager for Yii

php-tmpfilePHP 6

A convenience class for temporary files

yii2-apidoc-vimPHP 5

Yii2 apidoc as Vim helpfiles

php-orientdbPHP 5

A fast PHP driver for the OrientDB binary protocol.

translatablePHP 4

Transparent attribute translation for ActiveRecords

YiiUsersPHP 4

User management for Yii

Yii-Resource-ManagerPHP 3

Helpers to allow Yii to interact with resources (files) of different types

flushablePHP 3

Yii dependency that allows to flush records from the cache

bs3activeformPHP 2

A lightweight utility to render Bootstrap 3 forms in Yii

YiiEmailerPHP 2

Emailing functions for Yii

AccessRestrictablePHP 2

A Yii ActiveRecordBehavior that automatically applies conditions for access restriction to every query.

YiiLinkablePHP 1

A simple extension for Yii allowing easy and consistent access to model URLs and appropriate anchor text.

defaultpersisterPHP 1

Yii extension to save and restore model values in user session.

hybridauthmanagerPHP 1

An AuthManager for Yii that stores the hierarchy in a flat PHP file and the assignments in DB

YiiYaaPHP 1

YAA is an additional abstraction layer for Yii that aggregates a number of child models into a clean single model that is easy to cache

YiiAbstractArrayModelPHP

Work with PHP files in Active Record way

twittonioPHP

simple useless twitter client

yii2-base-appPHP

An alternative Yii2 application template for purists

xreturnablePHP

Yii extension to create URLs that allow to return to a page by storing its GET Parameters on a stack.