GitVersion
, (*1)
PHP library to get the Git version of the project., (*2)
This library does not depend on the Git., (*3)
Installation
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this library:, (*4)
$ composer require antalaron/git-version
This command requires you to have Composer installed globally, as explained
in the installation chapter
of the Composer documentation., (*5)
Usage
To get the version:, (*6)
$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., (*7)
There is a second $hashLenght parameter in the methods. With that, you will get
the first n character of the hash., (*8)
To get the latest commit message:, (*9)
$gitVersion = new \Antalaron\GitVersion\GitVersion();
$gitVersion->getLatestCommit(__DIR__);
// or static
\Antalaron\GitVersion\GitVersion::getGitLatestCommit(__DIR__);
On error, the return value is null., (*10)
To get the latest commit object:, (*11)
$gitVersion = new \Antalaron\GitVersion\GitVersion();
$gitVersion->getLatestCommitDetails(__DIR__);
// or static
\Antalaron\GitVersion\GitVersion::getGitLatestCommitDetails(__DIR__);
License
This project is under MIT License., (*12)