PHPackages                             typisttech/composer-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. [CLI &amp; Console](/categories/cli)
4. /
5. typisttech/composer-semver

ActiveProject[CLI &amp; Console](/categories/cli)

typisttech/composer-semver
==========================

Static linked CLI wrapper for composer/semver. Parsing and validating versions exactly like Composer does without installing PHP.

v1.0.6(8mo ago)01[10 PRs](https://github.com/typisttech/composer-semver/pulls)MITGoPHP ~8.4.13CI passing

Since Oct 11Pushed 2w agoCompare

[ Source](https://github.com/typisttech/composer-semver)[ Packagist](https://packagist.org/packages/typisttech/composer-semver)[ Docs](https://github.com/typisttech/composer-semver)[ Fund](https://typist.tech/donation/)[ GitHub Sponsors](https://github.com/tangrufus)[ RSS](/packages/typisttech-composer-semver/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (9)Versions (29)Used By (0)

Composer SemVer
===============

[](#composer-semver)

[![GitHub Release](https://camo.githubusercontent.com/55977391abbade70305016a38c421b02037a967ec1cbad4a506799e4038e5d6c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f747970697374746563682f636f6d706f7365722d73656d766572)](https://github.com/typisttech/composer-semver/releases)[![Test](https://github.com/typisttech/composer-semver/actions/workflows/test.yml/badge.svg)](https://github.com/typisttech/composer-semver/actions/workflows/test.yml)[![License](https://camo.githubusercontent.com/5d291257ad1e5667c69cb9371603ede7dd9ddb423bae691b8f3b620845e930df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f747970697374746563682f636f6d706f7365722d73656d7665722e737667)](https://github.com/typisttech/composer-semver/blob/master/LICENSE)[![Follow @TangRufus on X](https://camo.githubusercontent.com/7415ea9d2391e64fc2a35887d01d58c13cac70988c9ecc62b57bc7fee6104de5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f466f6c6c6f772d54616e6752756675732d3135323032423f6c6f676f3d78266c6f676f436f6c6f723d7768697465)](https://x.com/tangrufus)[![Follow @TangRufus.com on Bluesky](https://camo.githubusercontent.com/6d838460816d5ab6e0e1f911a11f2731f12f3538761d12b8638f32861fcf2e1a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f426c7565736b792d54616e6752756675732e636f6d2d626c75653f6c6f676f3d626c7565736b79)](https://bsky.app/profile/tangrufus.com)[![Sponsor @TangRufus via GitHub](https://camo.githubusercontent.com/49753abc8cb53b971b0e46dec52e9ed32eaebf73be15ce3963306559a3ec7ccb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d54616e6752756675732d4541344141413f6c6f676f3d67697468756273706f6e736f7273)](https://github.com/sponsors/tangrufus)[![Hire Typist Tech](https://camo.githubusercontent.com/13f50b9bd2301613833b4f0ac55700b2f1c297c0fff7ba45a2a98b6c938a18db/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f486972652d547970697374253230546563682d373738383939)](https://typist.tech/contact/)

 **Static linked CLI wrapper for [`composer/semver`](https://packagist.org/packages/composer/semver).**
 Parsing and validating versions exactly like Composer does **without installing PHP**.

 Built with ♥ by [Typist Tech](https://typist.tech/)

---

Usage
-----

[](#usage)

### Normalize Versions

[](#normalize-versions)

Normalizes a version string to be able to perform comparisons on it. This is a wrapper of the [`Composer\Semver\VersionParser::normalize()`](https://github.com/composer/semver/blob/b52829022cb18210bb84e44e457bd4e890f8d2a7/src/VersionParser.php#L98-L108) method.

```
$ composer-semver normalize '1.2-p.5+foo'
1.2.0.0-patch5

# Status code 0 means valid versions
$ echo $?
0

$ composer-semver normalize 'not-a-version'

 [ERROR] Invalid version string "not-a-version"

# Non-zero status codes mean invalid versions
$ echo $?
1

$ composer-semver normalize --help
Description:
  Normalizes a version string to be able to perform comparisons on it

Usage:
  normalize [options] [--]

Arguments:
  version

Options:
      --full-version=FULL-VERSION  Complete version string to give more context.
  -h, --help                       Display help for the given command. When no command is given display help for the list command
      --silent                     Do not output any message
  -q, --quiet                      Only errors are displayed. All other output is suppressed
  -V, --version                    Display this application version
      --ansi|--no-ansi             Force (or disable --no-ansi) ANSI output
  -n, --no-interaction             Do not ask any interactive question
  -v|vv|vvv, --verbose             Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  This is a wrapper of the Composer\Semver\VersionParser::normalize() method.
```

### Parse Constraints

[](#parse-constraints)

Parses a constraint string and strip its ignorable parts. This is a wrapper of the [`Composer\Semver\VersionParser::parseConstraints()`](github.com/composer/semver/blob/b52829022cb18210bb84e44e457bd4e890f8d2a7/src/VersionParser.php#L251-L258) method.

```
$ composer-semver parse '>=1.2 1.2'

 [ERROR] Could not parse version constraint ~>1.2: Invalid operator "~>", you probably meant to use the "~"
         operator

# Non-zero status codes mean invalid constraints
$ echo $?
1

$ composer-semver parse --help
Description:
  Parses a constraint string and strip its ignorable parts

Usage:
  parse

Arguments:
  constraints

Options:
  -h, --help            Display help for the given command. When no command is given display help for the list command
      --silent          Do not output any message
  -q, --quiet           Only errors are displayed. All other output is suppressed
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  This is a wrapper of the Composer\Semver\VersionParser::parseConstraints() method.
```

### Print Bundled PHP and `composer/semver` Versions

[](#print-bundled-php-and-composersemver-versions)

```
$ composer-semver --version
```

### Dump Shell Completion Scripts

[](#dump-shell-completion-scripts)

For shell completions, follow the instructions from:

```
$ composer-semver completion --help
```

If you installed `Composer SemVer` [via Homebrew](#homebrew-macos--linux-recommended), completion scripts are managed by Homebrew. Read more at

---

Tip

**Hire Tang Rufus!**

I am looking for my next role, freelance or full-time. If you find this tool useful, I can build you more weird stuff like this. Let's talk if you are hiring PHP / Ruby / Go developers.

Contact me at

---

Why
---

[](#why)

> Which version numbering system does Composer itself use?
>
> Composer uses Semantic Versioning (aka SemVer) 2.0.0.
>
> \-- [Composer FAQ](https://getcomposer.org/doc/faqs/which-version-numbering-system-does-composer-itself-use.md)

Under the hood, Composer uses [`composer/semver`](https://packagist.org/packages/composer/semver) to parse and validate versions.

Despite the lie on [Composer FAQ](https://getcomposer.org/doc/faqs/which-version-numbering-system-does-composer-itself-use.md), the [fragmentary documentation](https://getcomposer.org/doc/articles/versions.md), and the deceitful package name `composer/semver`, Composer implements only a subset of [Semantic Versioning](https://semver.org/) specification while supports some uncommon versioning schemes. Working with Composer packages versions without `composer/semver` is a bit tricky.

*"A bit tricky"* is an understatement.

VersionValidity`1.2.3`✅ Valid.`1.2.3.4`✅ Valid. But not SemVer compliant.`1.0.0-a`✅ Valid.`1.0.0-b`✅ Valid.`1.0.0-c`❌ Invalid. But SemVer compliant. Composer only accepts [a limited sets of pre-release versions](https://github.com/composer/semver/blob/b52829022cb18210bb84e44e457bd4e890f8d2a7/src/VersionParser.php#L26-L39).`99999`✅ Valid. Composer normalize it to `99999.0.0.0`.`100000.0.0`✅ Valid`100000.0.0.0`❌ Invalid. Starting from `100000`, Composer treats it as CalVer which cannot have 4 bits.`2010-01-02`✅ Valid.`2010-01-02-10-20-30.5`✅ Valid.`20100102-203040`✅ Valid.`20100102.0.3.4`❌ Invalid. CalVer cannot have 4 bits.`2023013.0.0`❌ Invalid. `YYYYMMD` is a bad CalVer major version.`202301311.0.0`❌ Invalid. `YYYYMMDDh` is a bad CalVer major version.`20230131000.0.0`❌ Invalid.`YYYYMMDDhhm` is a bad CalVer major version.`2023013100000.0.0`❌ Invalid. `YYYYMMDDhhmmX` is a bad CalVer major version.`000.001.003.004`✅ Valid. Composer normalizes it to `000.001.003.004`. The leading zeros are significant and cannot be ignored.`0700`✅ Valid. Composer normalizes it to `0700.0.0.0`. The leading zero is significant and cannot be ignored.`1.00.000`✅ Valid. Composer normalizes it to `1.00.000.0`. All the zeroes are significant and cannot be ignored.`Composer SemVer` wraps `composer/semver` and the PHP runtime as a static linked CLI tool, so you can work with the package versions exactly like Composer does without installing PHP.

Tip

**Hire Tang Rufus!**

There is no need to understand any of these quirks. Let me handle them for you. I am seeking my next job, freelance or full-time.

If you are hiring PHP / Ruby / Go developers, contact me at

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

[](#installation)

### Homebrew (macOS / Linux) (Recommended)

[](#homebrew-macos--linux-recommended)

```
brew tap typisttech/tap
brew install typisttech/tap/composer-semver
```

### `apt-get` (Debian based distributions, for example: Ubuntu)

[](#apt-get-debian-based-distributions-for-example-ubuntu)

```
curl -1sLf 'https://dl.cloudsmith.io/public/typisttech/oss/setup.deb.sh' | sudo -E bash
sudo apt-get install composer-version
```

Instead of the automatic setup script, you can manually configure the repository with the instructions on [Cloudsmith](https://cloudsmith.io/~typisttech/repos/oss/setup/#formats-deb).

### Manual `.deb` (Debian based distributions, for example: Ubuntu)

[](#manual-deb-debian-based-distributions-for-example-ubuntu)

Warning

If you install the `.deb` file manually, you have to take care of updating it by yourself.

Download the latest `.deb` file from [GitHub Releases](https://github.com/typisttech/composer-semver/releases/latest), or via [`gh`](https://cli.github.com/):

```
# Both arm64 (aarch64) and amd64 (x86_64) architectures are available.
gh release download --repo 'typisttech/composer-semver' --pattern 'composer-semver_linux_arm64.deb'
```

**Optionally**, verify the `.deb` file:

```
gh attestation verify --repo 'typisttech/composer-semver' 'composer-semver_linux_arm64.deb'
```

Finally, install the package:

```
sudo dpkg -i composer-semver_linux_arm64.deb
```

Manual Binary
-------------

[](#manual-binary)

Warning

If you install the binary manually, you have to take care of updating it by yourself.

Download the latest `.tar.gz` file from [GitHub Releases](https://github.com/typisttech/composer-semver/releases/latest), or via [`gh`](https://cli.github.com/):

```
# Both darwin (macOS) and linux operating systems are available.
# Both arm64 (aarch64) and amd64 (x86_64) architectures are available.
gh release download --repo 'typisttech/composer-semver' --pattern 'composer-semver_darwin_arm64.tar.gz'
```

**Optionally**, verify the `.tar.gz` file:

```
gh attestation verify --repo 'typisttech/composer-semver' 'composer-semver_darwin_arm64.tar.gz'
```

Finally, unarchive and move the binary into `$PATH`:

```
tar -xvf 'composer-semver_darwin_arm64.tar.gz'

# Or, move it to any directory under `$PATH`
mv composer-semver /usr/local/bin
```

Alternatives
------------

[](#alternatives)

- [ComVer](https://github.com/typisttech/comver)
    A failed attempt to re-implement `composer/semver` in Go. It only supports a subset of Composer versioning.

Credits
-------

[](#credits)

[`Composer SemVer`](https://github.com/typisttech/composer-semver) is a [Typist Tech](https://typist.tech) project and maintained by [Tang Rufus](https://x.com/TangRufus), freelance developer [for hire](https://typist.tech/contact/).

Full list of contributors can be found [on GitHub](https://github.com/typisttech/composer-semver/graphs/contributors).

Copyright and License
---------------------

[](#copyright-and-license)

This project is a [free software](https://www.gnu.org/philosophy/free-sw.en.html) distributed under the terms of the MIT license. For the full license, see [LICENSE](./LICENSE).

Contribute
----------

[](#contribute)

Feedbacks / bug reports / pull requests are welcome.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance80

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

8

Last Release

258d ago

Major Versions

v0.6.1 → v1.0.02025-10-11

### Community

Maintainers

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

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (30 commits)")[![tangrufus](https://avatars.githubusercontent.com/u/2259834?v=4)](https://github.com/tangrufus "tangrufus (29 commits)")[![tastendruck[bot]](https://avatars.githubusercontent.com/u/25708257?v=4)](https://github.com/tastendruck[bot] "tastendruck[bot] (3 commits)")

---

Tags

clicomposersemantic-versioningsemvercomposerclivalidationsemverversioningsemantic

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k60.6M803](/packages/drush-drush)

PHPackages © 2026

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