PHPackages                             angrybytes/project-versioner - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. angrybytes/project-versioner

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

angrybytes/project-versioner
============================

A tool to maintain project/sub-project versions based on Composer, file mtimes, etc.

4.0.0(1y ago)037.8kMITPHPPHP 8.2 - 8.4

Since Sep 15Pushed 1y ago8 watchersCompare

[ Source](https://github.com/AngryBytes/php-project-versioner)[ Packagist](https://packagist.org/packages/angrybytes/project-versioner)[ RSS](/packages/angrybytes-project-versioner/feed)WikiDiscussions 4.0 Synced today

READMEChangelog (8)Dependencies (5)Versions (17)Used By (0)

PHP Project Versioner
=====================

[](#php-project-versioner)

[![PHP checks](https://github.com/AngryBytes/php-project-versioner/workflows/PHP%20checks/badge.svg)](https://github.com/AngryBytes/php-project-versioner/actions?query=workflow%3A%22PHP+checks%22)

**Note:** this is a fork of the original project as it appears to be abandoned.

This is a simple tool to obtain "versions" for projects in PHP.

Installation
------------

[](#installation)

Installation through composer:

```
composer require naneau/project-versioner=~0
```

Examples
--------

[](#examples)

This library is based around a "Versioner", which accepts one or more "Readers".

### Using Git

[](#using-git)

If your project is maintained using Git, you can look at it for versions.

#### Commit

[](#commit)

Use the last commit as a version:

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\Git\Commit\Exec as GitCommitReader;

// Create a versioner
$versioner = new Versioner([new GitCommitReader]);

// Short commit hash like "gd8587c8"
$version = $versioner->get('/foo/bar');
```

#### Tag

[](#tag)

Use the latest tag (reachable from this commit):

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\Git\Tag\Exec as GitTagReader;

// Create a versioner
$versioner = new Versioner([new GitTagReader]);

// Last tag
$version = $versioner->get('/foo/bar');
```

#### Described Version

[](#described-version)

Use the output of [`git describe`](http://git-scm.com/docs/git-describe), which combines the latest (reachable) tag and subsequent commits:

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\Git\Tag\Exec as GitTagReader;

// Create a versioner
$versioner = new Versioner([new GitTagReader]);

// Last tag + commit info, like 4.3.2-9-gd504031
$version = $versioner->get('/foo/bar');
```

### Using Files

[](#using-files)

#### Reading Version From A Single File

[](#reading-version-from-a-single-file)

Imagine you maintain a file called `VERSION` that you (or your CI stack) fills with a version.

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\File as FileReader;

// Create a versioner
$versioner = new Versioner([
    // Reader for "VERSION" file
    new FileReader('VERSION')
]);

// Retrieve version from versioner
$version = $versioner->get('/foo/bar');
```

#### Using MTime

[](#using-mtime)

In a common scenario, a set of files is (independently) updated, and you want to use the highest/most recent time (`mtime`) as a version. This version can be used to bust caches, etc.:

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\Finder\MTime as MTimeReader;

// Create a versioner
$versioner = new Versioner([
    new MTimeReader('*.txt') // Look at all *.txt files
]);

// Highest mtime, like 1410806782
$version = $versioner->get('/foo/bar');
```

#### Using Contents

[](#using-contents)

Using a different reader it is possible to use the *contents* of the files found:

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\Finder\Contents as ContentsReader;

$versioner = new Versioner([
    new ContentsReader('*.jpg')
]);

// Short hash of file contents, like gd504031
$version = $versioner->get('/foo/bar');
```

### Composer

[](#composer)

If your project depends on a set of [Composer](https://getcomposer.org) dependencies, you can use the Composer readers to obtain a version based on installed packages.

#### All Packages

[](#all-packages)

To look at all packages combined:

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\Composer as ComposerReader;

$versioner = new Versioner([new ComposerReader]);

// Short hash like "ae9b8a"
$version = $versioner->get('/foo/bar');
```

#### Using A Specific Package

[](#using-a-specific-package)

Or, looking for a specific package:

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\ComposerPackage as ComposerPackageReader;

$versioner = new Versioner([
    new ComposerPackageReader('symfony/filesystem')
]);

// Composer Version (SemVer) like "v2.5.4"
$version = $versioner->get('/foo/bar');
```

Combining Readers
-----------------

[](#combining-readers)

For some projects you may want to combine readers, for instance as a fallback mechanism if one reader does not provide output, or to get a version composed of more than one reader's output.

Combining Composer and Git:

```
use Naneau\ProjectVersioner\Versioner;
use Naneau\ProjectVersioner\Reader\ComposerPackage as ComposerPackageReader;
use Naneau\ProjectVersioner\Reader\Git\Tag\Exec as GitTagReader;

$versioner = new Versioner([
    new ComposerPackageReader('symfony/filesystem'),
    new GitTagReader
]);

// First version found
$version = $versioner->get('/foo/bar');

// Composite of all readers, like "v0.3.4-gd504031"
$combinedVersion = $versioner->getCombined('/foo/bar');

// You can specify the separator
$combinedVersionUnderscore = $versioner->getCombined('/foo/bar', '_');
```

Notes
-----

[](#notes)

- Obtaining a version inevitably uses (potentially expensive) I/O. You may want to cache the results.
- The `exec` based Git readers are UN\*X only for now

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance40

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity89

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~234 days

Recently: every ~165 days

Total

17

Last Release

512d ago

Major Versions

0.0.1 → 1.0.12014-09-18

1.2.x-dev → 2.0.02021-12-22

2.0.x-dev → 3.0.02023-12-01

3.0.x-dev → 4.0.02024-12-13

PHP version history (6 changes)1.1.0PHP 7.2.\* || 7.3.\* || 7.4.\*

1.2.0PHP 7.3.\* || 7.4.\* || 8.0.\*

2.0.0PHP 7.4.\* || 8.0.\* || 8.1.\*

2.0.1PHP 7.4.\* || 8.0.\* || 8.1.\* || 8.2.\*

3.0.0PHP 8.1.\* || 8.2.\* || 8.3.\*

4.0.0PHP 8.2 - 8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2d7c104d03e59c7603a91d0292e83e62454647795ffd925d11001fc6edc37c6?d=identicon)[angrybytes](/maintainers/angrybytes)

---

Top Contributors

[![naneau](https://avatars.githubusercontent.com/u/89551?v=4)](https://github.com/naneau "naneau (31 commits)")[![t0mmie](https://avatars.githubusercontent.com/u/953495?v=4)](https://github.com/t0mmie "t0mmie (24 commits)")[![stephank](https://avatars.githubusercontent.com/u/89950?v=4)](https://github.com/stephank "stephank (9 commits)")[![ivarb](https://avatars.githubusercontent.com/u/849042?v=4)](https://github.com/ivarb "ivarb (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/angrybytes-project-versioner/health.svg)

```
[![Health](https://phpackages.com/badges/angrybytes-project-versioner/health.svg)](https://phpackages.com/packages/angrybytes-project-versioner)
```

###  Alternatives

[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M81](/packages/symplify-monorepo-builder)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

96374.6k23](/packages/friendsoftypo3-content-blocks)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
