PHPackages                             jbuncle/php-autosemver - 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. [DevOps &amp; Deployment](/categories/devops)
4. /
5. jbuncle/php-autosemver

ActiveProject[DevOps &amp; Deployment](/categories/devops)

jbuncle/php-autosemver
======================

1.0.3(4y ago)0103GPL-3.0-or-laterPHPPHP &gt;=7.2

Since Apr 26Pushed 4y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (39)Used By (0)

PHP Automatic Semantic Versioning Detector
==========================================

[](#php-automatic-semantic-versioning-detector)

[![Latest Version](https://camo.githubusercontent.com/9adde11a761a14853dcbf0fe9ee35abf02085137ae59d74b8d9a186c6d1ec51f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6a62756e636c652f7068702d6175746f73656d7665723f736f72743d73656d766572266c6162656c3d676974687562)](https://github.com/jbuncle/php-autosemver/)[![Packagist Version](https://camo.githubusercontent.com/30325ae33f144f03d267b1599f82b01a8143ca33214cea2c3b8b465cf47800f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a62756e636c652f7068702d6175746f73656d766572)](https://packagist.org/packages/jbuncle/php-autosemver)[![Docker Image Version (latest semver)](https://camo.githubusercontent.com/372211b6e0ef2038d8dab02e6456efc3bb7d06be57ec599e5a33caef34c4aca2/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f762f6a62756e636c652f7068702d6175746f73656d7665723f6c6162656c3d646f636b6572266c6f676f3d646f636b657225323076657273696f6e26736f72743d73656d766572)](https://hub.docker.com/r/jbuncle/php-autosemver)

[![Build Status](https://camo.githubusercontent.com/5cbecc76ee02bc5920cf2e29b1853ff723c272f32caa88f1ba22b0f0e7c6cc57/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f636c6f75642f6275696c642f6a62756e636c652f7068702d6175746f73656d766572)](https://hub.docker.com/r/jbuncle/php-autosemver)[![Packagist PHP Version Support](https://camo.githubusercontent.com/f32628bab43c79d97633fb4689626c1c25af628354fa219fe421fe6758fbc97b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a62756e636c652f7068702d6175746f73656d766572)](https://camo.githubusercontent.com/f32628bab43c79d97633fb4689626c1c25af628354fa219fe421fe6758fbc97b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a62756e636c652f7068702d6175746f73656d766572)[![LICENCE](https://camo.githubusercontent.com/b868d17b0e65ef39e684b102376431699cbc8973eaec12b9f1786483bd33cc7c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a62756e636c652f7068702d6175746f73656d766572)](https://github.com/jbuncle/php-autosemver/blob/master/LICENSE)

*Still in development, though largely stable*

**Manage your PHP library versions automatically**

Automatically calculates the Semantic Version (SemVer) increment automatically based on source code changes between different Git references (revisions, tags, etc). This increment can then be used to determine the next version number (e.g. using the built in `composer-version` command).

Given two Git revisions (or a Working Copy), it will return **MAJOR**, **MINOR** or **PATCH** based on the changes between those revisions, based on Semantic Versioning rules (see ).

This allows the versioning process to be fully automated, where you would otherwise require a manual step to set the version would be required.

There are some edge cases, however automation is probably still better than manually maintaining semantic versions since such processes take time and are prone to human error.

Installation with Composer
--------------------------

[](#installation-with-composer)

Install globally:

```
composer global require jbuncle/php-autosemver
```

Basic Usage
-----------

[](#basic-usage)

*With composer*

```
cd
php-autosemver
```

*With docker*

```
cd
docker run -v $(pwd):/app -it --rm jbuncle/php-autosemver
```

A "revision" can be a commit, tag, branch, `HEAD`, or `WC` (use working copy).

Examples
--------

[](#examples)

### Compare your working copy to Git

[](#compare-your-working-copy-to-git)

Run from your the root of your project.

*With composer global*

```
php-autosemver --verbosity=1 HEAD WC
```

*With Docker*

```
docker run -v $(pwd):/app -it --rm jbuncle/php-autosemver bash -c "php-autosemver --verbosity=1 HEAD WC"
```

Useful for checking whether your commit introduces an API breaking change and print out the relevant differences.

### Automatically tag current Git revision

[](#automatically-tag-current-git-revision)

Create a Git tag by comparing current revision to last tag.

*With composer*

```
# Ensure we have fetched existing tags
git fetch --tags

# Calculate the version number using php-autosemver
LATEST_TAG=$(latesttag);
INCREMENT=$(php-autosemver ${LAST_VERSION});
NEW_VERSION=$(composer-version --inc ${LATEST_TAG} ${INCREMENT});

# Create the tag and push it
git tag ${NEW_VERSION}
git push origin ${NEW_VERSION}
```

*With Docker*

```
# Ensure we have fetched existing tags
git fetch --tags

# Calculate the version number using php-autosemver docker image
NEW_VERSION=$(docker run -it --rm -v $(pwd):/app jbuncle/php-autosemver bash -c '\
LATEST_TAG=$(latesttag);\
INCREMENT=$(php-autosemver ${LATEST_TAG});\
composer-version --inc ${LATEST_TAG} ${INCREMENT}')

# Create the tag and push it
git tag ${NEW_VERSION}
git push origin ${NEW_VERSION}
```

How it works
------------

[](#how-it-works)

The tool parses all the PHP files and generates a list of all the possible, accessible signatures (including variations) found. For Git revisions it will traverse the Git commit directly using the Git CLI (therefore the `git` command is required).

Once generated for both sets of changes, it will compare the generated signature strings lists looking for removed signatures (**MAJOR** change), new signatures (**MINOR** change) or no signature changes (**PATCH**).

For example, the following in PHP code:

```
 namespace MyNamespace;
 class SomeClass {
    public function aMethod($a, $b = 0) {}
 }
```

Would be interpreted into 3 unique signature variations:

```
\MyNamespace\SomeClass->aMethod(mixed, mixed = 0)
\MyNamespace\SomeClass->aMethod(mixed, mixed)
\MyNamespace\SomeClass->aMethod(mixed)

```

Known Edge Cases
----------------

[](#known-edge-cases)

- Changing method signature to be a [variadic](https://www.php.net/manual/en/functions.arguments.php#functions.variable-arg-list) will show as breaking change, even if the change is backward compatible.
- Inherited changes as a result of updates to parent classes/traits that exist outside search directory won't be detected
- Adding a constructor with a signature that matches the parent will show as a breaking changes
- Adding a return type that was previously not type hinted will show as a breaking change, even if the type matches what was previously returned (technically this is a breaking changes as method might be overridden and then not match).
- Removing a type parameter will show as breaking change
- Doesn't recognise an addition of a method signature to an interface as a breaking change.

Improvements
------------

[](#improvements)

- Make more aware of composer
    - Inspect composer dependencies (if a dependency has incremented, then this project should match the increment)
    - Inspect autoload paths (don't worry about classes that can't/shouldn't be accessed)
- Only bother parsing files that have changed
- Analyse parent classes for additional, inherited signatures
- Treat addition of a signature to an interface as a breaking change
- Ignore change of default values on parameters (these aren't breaking changes)
- Don't treat making abstract class non-abstract as a breaking change
- Subversion (SVN) support

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~50 days

Total

3

Last Release

1747d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d2b61c26f3cae0b6e0b8c9e07555b189fe71e5b141e5e1a8129acaace3f674d?d=identicon)[jbuncle](/maintainers/jbuncle)

---

Top Contributors

[![jbuncle](https://avatars.githubusercontent.com/u/11473689?v=4)](https://github.com/jbuncle "jbuncle (60 commits)")

---

Tags

automatic-versioningcheckercidetectordevopsdevops-toolsdockerphppipelinesemantic-versioningsemver

### Embed Badge

![Health badge](/badges/jbuncle-php-autosemver/health.svg)

```
[![Health](https://phpackages.com/badges/jbuncle-php-autosemver/health.svg)](https://phpackages.com/packages/jbuncle-php-autosemver)
```

###  Alternatives

[deployer/deployer

Deployment Tool

11.0k25.4M207](/packages/deployer-deployer)[appwrite/server-ce

End to end backend server for frontend and mobile apps.

55.3k84.2k](/packages/appwrite-server-ce)[pragmarx/health

Laravel Server &amp; App Health Monitor and Notifier

2.0k1.0M2](/packages/pragmarx-health)[felixfbecker/language-server-protocol

PHP classes for the Language Server Protocol

22476.7M6](/packages/felixfbecker-language-server-protocol)[heroku/heroku-buildpack-php

Toolkit for starting a PHP application locally, with or without foreman, using the same config for PHP and Apache2/Nginx as on Heroku

8161.3M10](/packages/heroku-heroku-buildpack-php)[ideato/idephix

PHP automation and deploy tool.

6533.1k](/packages/ideato-idephix)

PHPackages © 2026

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