PHPackages                             dmamontov/git4p - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dmamontov/git4p

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dmamontov/git4p
===============

A native PHP git library

0.0.5(4y ago)076MITPHPPHP ^7.4

Since Aug 2Pushed 4y agoCompare

[ Source](https://github.com/dmamontov/git4p)[ Packagist](https://packagist.org/packages/dmamontov/git4p)[ RSS](/packages/dmamontov-git4p/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (7)Used By (0)

**Status:** No longer active / archived

[![Build Status](https://camo.githubusercontent.com/0648209f395b5d47d65f5488a5041567e79f162cf21459fe5408d2c114647fc0/68747470733a2f2f7472617669732d63692e6f72672f67697434702f67697434702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/git4p/git4p)[![Codacy Badge](https://camo.githubusercontent.com/15ce8080b97997137f4ead3c8b403884c9c1813de75ae97a696d3bc5d49337bb/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f636f7665726167652f3066636431363238343435653432313739316237613339626265666534316666)](https://www.codacy.com/app/martijn-niji/git4p)[![Codacy Badge](https://camo.githubusercontent.com/21d1b5ae56845583710962325d4e341dd71d8a967631c37e508f0e3adcb887d7/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f67726164652f3066636431363238343435653432313739316237613339626265666534316666)](https://www.codacy.com/app/martijn-niji/git4p)[![StyleCI](https://camo.githubusercontent.com/35d322ac20013ddb4960fb9fd7c8087e384d5d78da599a3517a38af5b4825564/68747470733a2f2f7374796c6563692e696f2f7265706f732f33353833363735302f736869656c64)](https://styleci.io/repos/35836750)

Git4P
=====

[](#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.

Please let me know how you're using this library.

Examples
--------

[](#examples)

### Create a new bare repository

[](#create-a-new-bare-repository)

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

### Add a simple blob

[](#add-a-simple-blob)

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

```
$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

[](#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.

```
$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
----

[](#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.

Some TODOs
----------

[](#some-todos)

- Add pack support
- Add proper phpdoc blocks

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~585 days

Total

5

Last Release

1603d ago

PHP version history (2 changes)v0.0.1-alphaPHP ^5.4

0.0.2PHP ^7.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5955726?v=4)[Dmitry Mamontov](/maintainers/dmamontov)[@dmamontov](https://github.com/dmamontov)

---

Top Contributors

[![mvdkleijn](https://avatars.githubusercontent.com/u/431452?v=4)](https://github.com/mvdkleijn "mvdkleijn (115 commits)")[![dmamontov](https://avatars.githubusercontent.com/u/5955726?v=4)](https://github.com/dmamontov "dmamontov (5 commits)")[![hifi](https://avatars.githubusercontent.com/u/106598?v=4)](https://github.com/hifi "hifi (1 commits)")

---

Tags

phpgitrepositorynative

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dmamontov-git4p/health.svg)

```
[![Health](https://phpackages.com/badges/dmamontov-git4p/health.svg)](https://phpackages.com/packages/dmamontov-git4p)
```

###  Alternatives

[marcocesarato/php-conventional-changelog

Generate changelogs and release notes from a project's commit messages and metadata and automate versioning with semver.org and conventionalcommits.org

2511.3M109](/packages/marcocesarato-php-conventional-changelog)[nilportugues/php_backslasher

Adds all PHP internal functions to its namespace by adding backslash to them. Improves the application's performance when OPCache is on.

889.3k18](/packages/nilportugues-php-backslasher)[wcm/git-php-hooks-library

A collection of Git PHP Hooks

1210.1k3](/packages/wcm-git-php-hooks-library)[nilportugues/php_todo

Looks into the code using a user-defined list of to-do phrases and stops commit if the total amount increased or is above a threshold.

1210.0k](/packages/nilportugues-php-todo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
