PHP library to get current Git version

v1.1.0 2018-01-27 15:24 UTC


Build Status Coverage Status

PHP library to get the Git version of the project.

This library does not depend on the Git.


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 of the Composer documentation.


To get the version:

$gitVersion = new \Antalaron\GitVersion\GitVersion();

// or static

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();

// or static

On error, the return value is null.


This project is under MIT License.