PHPackages                             abdelrahman/semantic-versioning - 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. abdelrahman/semantic-versioning

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

abdelrahman/semantic-versioning
===============================

PHP Package for managing semantic versions

1.0.1(8y ago)21151MITPHPPHP ~7.1

Since Apr 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/abdelrahmanrafaat/semantic-versioning)[ Packagist](https://packagist.org/packages/abdelrahman/semantic-versioning)[ RSS](/packages/abdelrahman-semantic-versioning/feed)WikiDiscussions master Synced 3d ago

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

semantic-versioning
===================

[](#semantic-versioning)

PHP package for parsing, comparing and modifying semantic versions

---

### Some theory about semantic versions

[](#some-theory-about-semantic-versions)

#### What is a semantic version ?

[](#what-is-a-semantic-version-)

- It`s a set of rules or conventions for documenting versions of a software
- A Software can be Project or Package or API

More detailed explination can be found =&gt;

---

### Piecies of semantic version

[](#piecies-of-semantic-version)

#### Normal version

[](#normal-version)

- The first and most important part of a semantic version
- Consists of three identifiers Major.Minor.Patch
- The three identifiers must be (non-negative integers with noleading zeros) \[0-9\]
- Major identifier must not be zero
- Minor and Patch identifiers can be zeros
- Major identifier has higher precedence than Minor identifier and Minor identifier has higher precedence than Patch identifier
- Example: 1.0.0 or 1.1.1 or 2.9.4

#### Pre Release

[](#pre-release)

- The secound part of a semantic version
- Comes after the normal version and starts with a hyphen -
- Consists of one or more non-empty identifiers seperated by .
- Identifiers must be (alphanumeric characters with/without a hyphen) \[0-9A-Za-z-\] or (non-negative integers with noleading zeros) \[0-9\]
- Alphanumeric identifiers has higher precedence than integers identifiers
- Pre Release has lower precedence than Normal version
- Example: 1.0.0-alpha or 1.0.0-alpha.1 or 1.0.0-0.3.7 or 1.0.0-x.7.z.92

#### Build Meta Data

[](#build-meta-data)

- The third part of a semantic version
- Comes after the normal version or pre release and starts with a hyphen +
- Consists of one or more non-empty identifiers seperated by .
- Identifiers must be (alphanumeric characters with/without a hyphen) \[0-9A-Za-z-\] or (non-negative integers with noleading zeros) \[0-9\]
- Build Meta data has no precedence when comparing two semantic versions
- Example: 1.0.0-alpha+001 or 1.0.0+20130313144700 or 1.0.0-beta+exp.sha.5114f85

---

### Package Installation

[](#package-installation)

```
$ composer require abdelrahman/semantic-versioning

```

---

### Package usage

[](#package-usage)

```
use Abdelrahmanrafaat\SemanticVersion\SemanticVersion;

$packageVersion = (new SemanticVersion)->setVersion('1.3.0-beta+exp.sha.5114f85');

$packageVersion->getFullVersion();   //1.3.0-beta.1+exp.sha.5114f85
$packageVersion->getNormalVersion(); //1.3.0
$packageVersion->getPreRelease();    //beta.1
$packageVersion->getBuildMetaData(); //exp.sha.5114f85

$packageVersion->getMajorVersion(); //1
$packageVersion->getMinorVersion(); //3
$packageVersion->getPatchVersion(); //0

$packageVersion->pumpMajor();
$packageVersion->getMajorVersion();  //2
$packageVersion->getNormalVersion(); //2.0.0

$packageVersion->pumpMinor();
$packageVersion->getMinorVersion(); //1
$packageVersion->getNormalVersion(); //2.1.0

$packageVersion->pumpPatch();
$packageVersion->getPatchVersion(); //1
$packageVersion->getNormalVersion(); //2.1.1

```

---

#### Comparing two versions

[](#comparing-two-versions)

- Depends on the precedence of normal version and pre release
- Build meta data gets ignored when comparing two semantic versions

```
$firstVersion   = (new SemanticVersion)->setVersion('1.1.1');
$secoundVersion = (new SemanticVersion)->setVersion('1.1.1');

$firstVersion->equals($secoundVersion); //true

$firstVersion->pumpMajor();
$firstVersion->equals($secoundVersion); //false
$firstVersion->greaterThan($secoundVersion); //true
$secoundVersion->lessThan($firstVersion); //true

$firstVersion = (new SemanticVersion)->setVersion('1.0.0-alpha');
$secoundVersion = (new SemanticVersion)->setVersion('1.0.0-rc');

$firstVersion->equals($secoundVersion); //false
$firstVersion->lessThan($secoundVersion); //true
$secoundVersion->greaterThan($firstVersion); //true

```

---

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

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

Total

2

Last Release

2950d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1835b07a3966bc9a8802036e36d1731a65fa6296a1511fc026a536edaea823f0?d=identicon)[abdelrahmanrafaat](/maintainers/abdelrahmanrafaat)

---

Top Contributors

[![abdelrahmanrafaat](https://avatars.githubusercontent.com/u/17337459?v=4)](https://github.com/abdelrahmanrafaat "abdelrahmanrafaat (22 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/abdelrahman-semantic-versioning/health.svg)

```
[![Health](https://phpackages.com/badges/abdelrahman-semantic-versioning/health.svg)](https://phpackages.com/packages/abdelrahman-semantic-versioning)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[symfony/event-dispatcher

Provides tools that allow your application components to communicate with each other by dispatching events and listening to them

8.6k985.9M3.4k](/packages/symfony-event-dispatcher)[symfony/polyfill-php80

Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions

1.7k815.2M457](/packages/symfony-polyfill-php80)[seld/phar-utils

PHAR file format utilities, for when PHP phars you up

875180.0M32](/packages/seld-phar-utils)[dansmith/laravel5-foundation

Zurb Foundation components for Laravel5

104.6k](/packages/dansmith-laravel5-foundation)

PHPackages © 2026

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