PHPackages                             stevegrunwell/semver-parser - 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. stevegrunwell/semver-parser

ActiveLibrary

stevegrunwell/semver-parser
===========================

Library for parsing and manipulating Semantic Versioning ("SemVer") relases

4142PHPCI failing

Since Oct 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/stevegrunwell/semver-parser)[ Packagist](https://packagist.org/packages/stevegrunwell/semver-parser)[ RSS](/packages/stevegrunwell-semver-parser/feed)WikiDiscussions develop Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

SemVer Parser
-------------

[](#semver-parser)

This library defines the `SteveGrunwell\SemVer\Version` class, which is meant to parse and manipulate version numbers based on [the rules of Semantic Versioning (a.k.a. "SemVer")](https://semver.org/).

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

[](#installation)

Install the library using [Composer](https://getcomposer.org/):

```
$ composer require stevegrunwell/semver-parser
```

Please note that while this library should be compatible with PHP 7.4 and newer, the unit tests are only run in CI against [actively-supported versions of PHP](https://www.php.net/supported-versions.php).

Usage
-----

[](#usage)

The constructor of the `Version` class can accept a valid, semantic version based on [the Semantic Versioning 2.0.0 specification](https://semver.org/spec/v2.0.0.html):

```
use SteveGrunwell\SemVer\Parser;

// Import the Composer-generated autoloader.
require_once __DIR__ . '/vendor/autoload.php';

$version = new Version('1.2.3-rc1+local');

// Parse the version.
$version->getMajorVersion();      // 1
$version->getMinorVersion();      // 2
$version->getPatchVersion();      // 3
$version->getPreReleaseVersion(); // rc1
$version->getBuildMetadata():     // local

// Modify the version.
$version->setMajorVersion(4);
$version->setMinorVersion(5);
$version->setPatchVersion(6);
$version->setPreReleaseVersion('rc2');
$version->setBuildMetadata('github-actions.ubuntu2404');

// Retrieve the updated version as a string.
$version->getVersion(); // "4.5.6-rc2+github-actions.ubuntu2404"
(string) $version;      // "4.5.6-rc2+github-actions.ubuntu2404"
```

### Additional methods

[](#additional-methods)

In addition to the setters and getters described above, each of the major, minor, and patch values have corresponding increment and decrement methods:

```
// Increment values.
$version->incrementMajorVersion();
$version->incrementMinorVersion();
$version->incrementPatchVersion();

// Decrement values.
$version->decrementMajorVersion();
$version->decrementMinorVersion();
$version->decrementPatchVersion();
```

It's worth noting that `incrementMajorVersion()` and `incrementMinorVersion()` will reset the the minor/patch and patch numbers (respectively) according to [the Semantic Versioning 2.0.0 specification](https://semver.org/spec/v2.0.0.html#spec-item-7).

License
-------

[](#license)

This library is released under the MIT License. Please see [LICENSE.md](LICENSE.md) for more details.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92.9% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/05f4d610f0de13ac1c23825f691fd05f2dd37ae9e8f0483e2dc4f1ca1e2bfb32?d=identicon)[stevegrunwell](/maintainers/stevegrunwell)

---

Top Contributors

[![stevegrunwell](https://avatars.githubusercontent.com/u/233836?v=4)](https://github.com/stevegrunwell "stevegrunwell (39 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")

---

Tags

composer-librarycomposer-packagephp-librarysemver

### Embed Badge

![Health badge](/badges/stevegrunwell-semver-parser/health.svg)

```
[![Health](https://phpackages.com/badges/stevegrunwell-semver-parser/health.svg)](https://phpackages.com/packages/stevegrunwell-semver-parser)
```

PHPackages © 2026

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