PHPackages                             andrelohmann/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. andrelohmann/semver

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

andrelohmann/semver
===================

parser for semantic versioning

v1.1.2(10y ago)01.3k1BSD-3-ClausePHPPHP &gt;=5.4

Since Sep 7Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (5)Used By (1)

\#SemVer

This is a [Semantic Versioning](http://semver.org/) 2.0.0 parser for PHP 5.4 and 5.5. It defines a simple interface `Parser` that validates that a version is properly formatted and parses it into a `Version` class:

```
namespace League\SemVer;

interface Parser
{

    /**
     * @param string $version
     * @return Version
     */
    function parse($version);

    /**
     * @param string $version
     * @return bool
     */
    function isValidVersion($version);

}
```

\##Usage

```
$parser = new League\SemVer\RegexParser();
var_dump($parser->parse('not a valid version'));
var_dump($parser->parse('1.0.0-alpha.1+48e4f51e0b2751ec3bc4a2bde809e46d60eb1d6e'));
```

Result:

```
NULL
object(League\SemVer\Version)#3 (5) {
  ["major"]=>
  string(1) "1"
  ["minor"]=>
  string(1) "0"
  ["patch"]=>
  string(1) "0"
  ["pre_release"]=>
  array(2) {
    [0]=>
    string(5) "alpha"
    [1]=>
    int(1)
  }
  ["build"]=>
  array(1) {
    [0]=>
    string(40) "48e4f51e0b2751ec3bc4a2bde809e46d60eb1d6e"
  }
}
```

Note that there is `CachingParser` that can be used to cache the results of parsing, but some preliminary tests indicate that reparsing the version is actually faster.

\##Requirements

- PHP 5.4 or 5.5
- PHPUnit (version unknown) - for running tests.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 65.7% 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 ~5 days

Total

3

Last Release

3895d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.2

v1.1.2PHP &gt;=5.4

### Community

Maintainers

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

---

Top Contributors

[![morrisonlevi](https://avatars.githubusercontent.com/u/253316?v=4)](https://github.com/morrisonlevi "morrisonlevi (23 commits)")[![andrelohmann](https://avatars.githubusercontent.com/u/617168?v=4)](https://github.com/andrelohmann "andrelohmann (12 commits)")

---

Tags

parsersemver

### Embed Badge

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

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

###  Alternatives

[nikic/php-parser

A PHP parser written in PHP

17.4k902.6M1.8k](/packages/nikic-php-parser)[doctrine/lexer

PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.

11.2k910.8M118](/packages/doctrine-lexer)[erusev/parsedown

Parser for Markdown.

15.0k151.8M732](/packages/erusev-parsedown)[league/commonmark

Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and GitHub-Flavored Markdown (GFM)

3.0k404.0M702](/packages/league-commonmark)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)

PHPackages © 2026

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