antalaron / git-version
PHP library to get current Git version
Installs: 2 708
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.5.9
Requires (Dev)
- phpunit/phpunit: ^4.0|^5.0|^6.0|^7.0|^8.0
Suggests
- ext-zlib: Needed to support extracting latest commit message
This package is auto-updated.
Last update: 2024-11-04 18:14:58 UTC
README
PHP library to get the Git version of the project.
This library does not depend on the Git.
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 of the Composer documentation.
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
This project is under MIT License.