PHPackages                             z4kn4fein/php-semver - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. z4kn4fein/php-semver

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

z4kn4fein/php-semver
====================

Semantic Versioning library for PHP. It implements the full semantic version 2.0.0 specification and provides ability to parse, compare, and increment semantic versions along with validation against constraints.

v3.0.0(2y ago)251.5M—4.9%5[1 PRs](https://github.com/z4kn4fein/php-semver/pulls)16MITPHPPHP &gt;=8.1CI passing

Since Dec 25Pushed 4mo ago1 watchersCompare

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

READMEChangelog (8)Dependencies (3)Versions (10)Used By (16)

php-semver
==========

[](#php-semver)

[![Build Status](https://github.com/z4kn4fein/php-semver/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/z4kn4fein/php-semver/actions/workflows/ci.yml)[![Latest Stable Version](https://camo.githubusercontent.com/f2d3a3754d909c001b37e38a54739464efcaa5497d74a02c196af5a7e6deb724/68747470733a2f2f706f7365722e707567782e6f72672f7a346b6e346665696e2f7068702d73656d7665722f76657273696f6e)](https://packagist.org/packages/z4kn4fein/php-semver)[![Total Downloads](https://camo.githubusercontent.com/780593206a8f85e1ff844a0261d40afd4c128d6fca4cb153f671534c5164bb1e/68747470733a2f2f706f7365722e707567782e6f72672f7a346b6e346665696e2f7068702d73656d7665722f646f776e6c6f616473)](https://packagist.org/packages/z4kn4fein/php-semver)[![Sonar Quality Gate](https://camo.githubusercontent.com/8fe24a2c6f6cc00594505c66323d425233ebd899581db99a35be11da22c0291a/68747470733a2f2f696d672e736869656c64732e696f2f736f6e61722f7175616c6974795f676174652f7a346b6e346665696e5f7068702d73656d7665723f6c6f676f3d736f6e6172636c6f7564267365727665723d6874747073253341253246253246736f6e6172636c6f75642e696f)](https://sonarcloud.io/project/overview?id=z4kn4fein_php-semver)[![Sonar Coverage](https://camo.githubusercontent.com/9c36da4e8d5b646d18b27aaadf19973798ee5117186fa158e36c25f7e4c82c47/68747470733a2f2f696d672e736869656c64732e696f2f736f6e61722f636f7665726167652f7a346b6e346665696e5f7068702d73656d7665723f6c6f676f3d536f6e6172436c6f7564267365727665723d6874747073253341253246253246736f6e6172636c6f75642e696f)](https://sonarcloud.io/project/overview?id=z4kn4fein_php-semver)

Semantic Versioning library for PHP. It implements the full [semantic version 2.0.0](https://semver.org/spec/v2.0.0.html) specification and provides ability to **parse**, **compare**, and **increment** semantic versions along with validation against **constraints**.

Requirements
------------

[](#requirements)

VersionPHP Version`>=1.0, =1.2, =3.0`&gt;=8.1Install with [Composer](https://getcomposer.org/)
-------------------------------------------------

[](#install-with-composer)

```
composer require z4kn4fein/php-semver
```

Usage
-----

[](#usage)

The following options are supported to construct a `Version`:

1. Building part by part with `Version::create()`.

    ```
    Version::create(3, 5, 2, "alpha", "build");
    ```
2. Parsing from a string with `Version::parse()` or `Version::parseOrNull()`.

    ```
    Version::parse("3.5.2-alpha+build");
    ```

The following information is accessible on a constructed `Version` object:

```
