Skip to content
This repository

PHP bindings for libgit2

branch: develop
Octocat-spinner-32 example [odb_backend] add refresh callback
Octocat-spinner-32 libgit2 @ 43cb8b3 add note for latest branch
Octocat-spinner-32 stubs add stub file
Octocat-spinner-32 tests cleanup tests
Octocat-spinner-32 .gitignore [tests] add stub codes
Octocat-spinner-32 .gitmodules wip
Octocat-spinner-32 LICENSE why i forgot to commit LICENSE file ?
Octocat-spinner-32 README.md add requirements
Octocat-spinner-32 attr.c fixes #59. correct variable declarations
Octocat-spinner-32 attr.h [diff] add diff_options interchange functions
Octocat-spinner-32 blame.c [blame] implement functions
Octocat-spinner-32 blame.h [blame] implement functions
Octocat-spinner-32 blob.c remove unused variables
Octocat-spinner-32 blob.h wip
Octocat-spinner-32 branch.c remove unused variables
Octocat-spinner-32 branch.h add several stubs
Octocat-spinner-32 checkout.c remove unused variables
Octocat-spinner-32 checkout.h add several stubs
Octocat-spinner-32 clone.c wip
Octocat-spinner-32 clone.h wip
Octocat-spinner-32 commit.c remove unused variables
Octocat-spinner-32 commit.h wip
Octocat-spinner-32 config.m4 [pathspec] implement several functions
Octocat-spinner-32 cred.c remove unused variables
Octocat-spinner-32 cred.h [diff] add diff_options interchange functions
Octocat-spinner-32 diff.c Fix for php_git2_diff_delta_to_array
Octocat-spinner-32 diff.h [diff] add diff_options interchange functions
Octocat-spinner-32 fe.php wip
Octocat-spinner-32 filter.c fixes #59. correct variable declarations
Octocat-spinner-32 filter.h [filter] add callbacks
Octocat-spinner-32 fixer.php add simple clang warning based unused variables fixer
Octocat-spinner-32 g_config.c Fix for unknown symbol convert_to_bool when running under Ubuntu Rari…
Octocat-spinner-32 g_config.h [diff] add diff_options interchange functions
Octocat-spinner-32 gen.php add several stubs
Octocat-spinner-32 giterr.c remove unused variables
Octocat-spinner-32 giterr.h add giterr
Octocat-spinner-32 graph.c remove unused variables
Octocat-spinner-32 graph.h add graph
Octocat-spinner-32 helper.c remove unused variables
Octocat-spinner-32 helper.h [status] implement git_status
Octocat-spinner-32 ignore.c remove unused variables
Octocat-spinner-32 ignore.h add several stubs
Octocat-spinner-32 index.c remove unused variables
Octocat-spinner-32 index.h [diff] add diff_options interchange functions
Octocat-spinner-32 indexer.c remove unused variables
Octocat-spinner-32 indexer.h [indexer] update code base
Octocat-spinner-32 merge.c remove unused variables
Octocat-spinner-32 merge.h add several stubs
Octocat-spinner-32 message.c remove unused variables
Octocat-spinner-32 message.h add message
Octocat-spinner-32 ng.php [indexer] update code base
Octocat-spinner-32 note.c remove unused variables
Octocat-spinner-32 note.h [diff] add diff_options interchange functions
Octocat-spinner-32 object.c fixes #59. correct variable declarations
Octocat-spinner-32 object.h add stubs
Octocat-spinner-32 odb.c fixes #59. correct variable declarations
Octocat-spinner-32 odb.h [odb] wip: backend
Octocat-spinner-32 packbuilder.c remove unused variables
Octocat-spinner-32 packbuilder.h [packbuilder] add callbacks
Octocat-spinner-32 patch.c remove unused variables
Octocat-spinner-32 patch.h [diff] add diff_options interchange functions
Octocat-spinner-32 pathspec.c remove unused variables
Octocat-spinner-32 pathspec.h add several stubs
Octocat-spinner-32 php_git2.c remove unused variables
Octocat-spinner-32 php_git2.h 0.3.0-dev Merge functions branch into develop.
Octocat-spinner-32 php_git2_priv.h [odb_backend] implement foreach callback. slightly tricky
Octocat-spinner-32 push.c remove unused variables
Octocat-spinner-32 push.h [remote] WIP: push
Octocat-spinner-32 ref.php add stub file
Octocat-spinner-32 reference.c fixes #59. correct variable declarations
Octocat-spinner-32 reference.h [diff] add diff_options interchange functions
Octocat-spinner-32 reflog.c remove unused variables
Octocat-spinner-32 reflog.h add reflog stubs
Octocat-spinner-32 refspec.c fixes #59. correct variable declarations
Octocat-spinner-32 refspec.h add refspec stubs
Octocat-spinner-32 remote.c fixes #59. correct variable declarations
Octocat-spinner-32 remote.h [remote] implement several functions
Octocat-spinner-32 repository.c [repository] remove unused variables
Octocat-spinner-32 repository.h [repository] implement git_repository_init_ext
Octocat-spinner-32 reset.c [reset] remove needles variables
Octocat-spinner-32 reset.h add reset
Octocat-spinner-32 revparse.c [revparse] improve codes
Octocat-spinner-32 revparse.h add several stubs
Octocat-spinner-32 revwalk.c remove unused variables
Octocat-spinner-32 revwalk.h wip
Octocat-spinner-32 signature.c remove unused variables
Octocat-spinner-32 signature.h add signature
Octocat-spinner-32 stash.c remove unused variables
Octocat-spinner-32 stash.h [stash] add stash callback
Octocat-spinner-32 status.c remove unused variables
Octocat-spinner-32 status.h [status] implement git_status
Octocat-spinner-32 submodule.c fixes #59. correct variable declarations
Octocat-spinner-32 submodule.h [submodule] implement submodule functions
Octocat-spinner-32 tag.c fixes #59. correct variable declarations
Octocat-spinner-32 tag.h [diff] add diff_options interchange functions
Octocat-spinner-32 transport.c remove unused variables
Octocat-spinner-32 transport.h [diff] add diff_options interchange functions
Octocat-spinner-32 tree.c remove unused variables
Octocat-spinner-32 tree.h wip
Octocat-spinner-32 treebuilder.c remove unused variables
Octocat-spinner-32 treebuilder.h [treebuilder] add filter function
README.md

PHP-Git2 - libgit2 bindings in PHP

php-git2 is a PHP bindings to the libgit2 linkable C Git library.

Requirements

PHP 5.3 above

Status

0.3.0 Alpha (switching to functions)

https://docs.google.com/spreadsheet/ccc?key=0AjvShWAWqvfHdDRneEtIUF9GRUZMNVVVR1hpdURiUWc&usp=sharing

How to build

# build libgit2.a
git submodule init && git submodule update
mkdir libgit2/build
cd libgit2/build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF ..
cmake --build .

# build php-git2
cd ../../
phpize
./configure --enable-git2-debug
make
make install
# add extension=git2.so to your php.ini

For Contributors

Issue first.

please make a issue first. don't work before creating it.

Coding Styles

follow pecl coding standards (except 8 at this moment).

Signature conversions
GIT_EXTERN(int) git_repository_init(
        git_repository **out,
        const char *path,
        unsigned is_bare);


// error code should handle in extension.
// resource creation or getting functions will return their resource or bool.
resource|bool function git_repository_init(string $path, long $is_bare);

public struct (e.g: git_config_entry) should consider return as an array.
file name rules.

basically, we rely libgit2 grouping at this time. (branch group functions should be in branch.c) some group (e.g config) will conflicts php header files. we choose g_ prefix for now.

check grouping here libgit2.github.com/libgit2/#v0.20.0

generating files

if you wanna try to work new file. please use gen.php and generate stubs. as declarations are bored task. (sometimes, this generator might output wrong headers. then just comment out or fix generator)

PRINT_HEADER=1 php ng.php libgit2/include/git2/branch.h > branch.h
php ng.php libgit2/include/git2/branch.h > branch.c

you can generate PHP_FE with this. past it to php_git2.c

php fe.php target.c

Note: usually, these generators might output needless variables. DON'T PR prettify codes at this moment. As we have more than 500 php functions. we like to use some fixer command than fix by hand.

documents

use prototype.

  /* {{{ proto int abs(int number)
     Returns the absolute value of the number */
  PHP_FUNCTION(abs)
  {
     ...
  }
  /* }}} */

document will generate later. please check source code before publish docs.

testing

[group]/[function].phpt

policy
  • don't create OOP interface in extension for ease of maintenance.
  • follow latest libgit2 api. don't consider BC at this time.

LICENSE

MIT License

Something went wrong with that request. Please try again.