PHPackages                             sydnerdrage/php-gitver - 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. sydnerdrage/php-gitver

ActiveLibrary

sydnerdrage/php-gitver
======================

v0.0.1(12y ago)036[1 issues](https://github.com/sydnerdrage/gitver/issues)PHP

Since Oct 7Pushed 12y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

gitver
======

[](#gitver)

Simple class to parse version tags from a git working directory.

[![Build Status](https://camo.githubusercontent.com/ad322b5d3ce5f2303e0e417924af304c2e70ffcfeda1e8f99fbb249017d8e56f/68747470733a2f2f7472617669732d63692e6f72672f7379646e657264726167652f6769747665722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/sydnerdrage/gitver)[![Coverage Status](https://camo.githubusercontent.com/29fba9f20a74159d2196a067eeb6e863b2276d4e94be486a4cab7d9fe02df7cb/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f7379646e657264726167652f6769747665722f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/sydnerdrage/gitver?branch=master)

Usage
-----

[](#usage)

Gitver defaults to the current working directory. As such it requires no immediate configuration

```
use \Gitver\Git;

$gitver = new Git(__DIR__);
echo $gitver->version();
```

This will output a `git describe` of the current working directory. e.g. v0.1.1-0-abcdefg

This is a combination of:

- Most recent tag (matching a $prefixX.Y.Z format - see configuration below)
- Number of commits since that tag
- Current commit prefixed with 'g' (identifying the repository as git).

Configuration
-------------

[](#configuration)

- Working directory to retrieve version from (defaults to the current working directory)
- Tag match prefix (defaults to "v")

For example if you version tags are in the format of release-X.Y.Z then you would call

```
$gitver = new Git(__DIR__, "version-");
```

#### CakePHP Sample

[](#cakephp-sample)

```
