The best way to install Git Repository Tags is using Composer:
$ composer require galek/git-repository-tags
$directory = __DIR__ . '/..'; // where we have directory `.git`, not end with `/` or `\`
$versionPrefix = 'v'; // prefix for version, default is v, so v1.0.0
$currentBranchVersion = true; // true|false , return version by HEAD of branch
$gitTags = new \Galek\GitRepositoryTags\GitRepositoryTags($directory, $versionPrefix, $currentBranchVersion);
// gets informations:
$tags = $gitTags->tags; // array of everyone tags
$versions = $gitTags->versions; // array of everyone tags with our version prefix
$latestVersion = $git->tags->latestVersion; // string, get full name of latest version
config.neon
extensions:
gitTags: Galek\GitRepositoryTags\DI\GitRepositoryTagsExtension
gitTags:
directory: %appDir%/..
versionPrefix: 'v'
byCurrentBranch: true
Presenter
class BasePresenter extends Presenter
{
/** @var \Galek\GitRepositoryTags\GitRepositoryTags @inject */
public $gitTags;
public function renderDefault()
{
$this->template->version = $this->gitTags->latestVersion;
$this->template->currentVersion = $this->gitTags->currentVersion;
}
}