PHPackages                             antalaron/git-version - 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. antalaron/git-version

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

antalaron/git-version
=====================

PHP library to get current Git version

v1.4.0(1y ago)14.8k1MITPHPPHP &gt;=5.5.9CI failing

Since Nov 14Pushed 1y ago1 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (14)Used By (0)

GitVersion
==========

[](#gitversion)

[![Tests](https://github.com/antalaron/git-version/actions/workflows/push.yaml/badge.svg?branch=master)](https://github.com/antalaron/git-version/actions/workflows/push.yaml/badge.svg?branch=master)

PHP library to get the Git version of the project.

This library does not depend on the Git.

Installation
------------

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:

```
$ composer require antalaron/git-version
```

This command requires you to have Composer installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

Usage
-----

[](#usage)

To get the version:

```
$gitVersion = new \Antalaron\GitVersion\GitVersion();
$gitVersion->getVersion(__DIR__);

// or static
\Antalaron\GitVersion\GitVersion::getGitVersion(__DIR__);
```

If no git found, then the return value is `null`.

There is a second `$hashLenght` parameter in the methods. With that, you will get the first n character of the hash.

To get the latest commit message:

```
$gitVersion = new \Antalaron\GitVersion\GitVersion();
$gitVersion->getLatestCommit(__DIR__);

// or static
\Antalaron\GitVersion\GitVersion::getGitLatestCommit(__DIR__);
```

On error, the return value is `null`.

To get the latest commit object:

```
$gitVersion = new \Antalaron\GitVersion\GitVersion();
$gitVersion->getLatestCommitDetails(__DIR__);

// or static
\Antalaron\GitVersion\GitVersion::getGitLatestCommitDetails(__DIR__);
```

License
-------

[](#license)

This project is under [MIT License](http://opensource.org/licenses/mit-license.php).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~265 days

Recently: every ~329 days

Total

10

Last Release

713d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/464e80a7b766518129809bfb8ac8b22e8c51d274d66f2423d66520772413134c?d=identicon)[antalaron](/maintainers/antalaron)

---

Top Contributors

[![antalaron](https://avatars.githubusercontent.com/u/9386504?v=4)](https://github.com/antalaron "antalaron (30 commits)")

---

Tags

gitphpphp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/antalaron-git-version/health.svg)

```
[![Health](https://phpackages.com/badges/antalaron-git-version/health.svg)](https://phpackages.com/packages/antalaron-git-version)
```

PHPackages © 2026

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