typisttech/composer-semver
Composer 安装命令:
composer create-project typisttech/composer-semver
包简介
Static linked CLI wrapper for composer/semver. Parsing and validating versions exactly like Composer does without installing PHP.
README 文档
README
Composer SemVer
Static linked CLI wrapper for composer/semver.
Parsing and validating versions exactly like Composer does without installing PHP.
Built with ♥ by Typist Tech
Usage
Normalize Versions
Normalizes a version string to be able to perform comparisons on it.
This is a wrapper of the Composer\Semver\VersionParser::normalize() 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] [--] <version> 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
Parses a constraint string and strip its ignorable parts.
This is a wrapper of the Composer\Semver\VersionParser::parseConstraints() method.
$ composer-semver parse '>=1.2 <2.0 || ~3.4.5 || ^6.7' [[>= 1.2.0.0-dev < 2.0.0.0-dev] || [>= 3.4.5.0-dev < 3.5.0.0-dev] || [>= 6.7.0.0-dev < 7.0.0.0-dev]] # Status code 0 means valid constraints $ echo $? 0 $ composer-semver parse '~>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 <constraints> 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
$ composer-semver --version
Dump Shell Completion Scripts
For shell completions, follow the instructions from:
$ composer-semver completion --help
If you installed Composer SemVer via Homebrew, completion scripts are managed by Homebrew.
Read more at https://docs.brew.sh/Shell-Completion
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 https://typist.tech/contact/
Why
Which version numbering system does Composer itself use?
Composer uses Semantic Versioning (aka SemVer) 2.0.0.
-- Composer FAQ
Under the hood, Composer uses composer/semver to parse and validate versions.
Despite the lie on Composer FAQ, the fragmentary documentation, and the deceitful package name composer/semver,
Composer implements only a subset of Semantic Versioning 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.
| Version | Validity |
|---|---|
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. |
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 https://typist.tech/contact/
Installation
Homebrew (macOS / Linux) (Recommended)
brew tap typisttech/tap brew install typisttech/tap/composer-semver
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.
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, or via gh:
# 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
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, or via gh:
# 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
- ComVer
A failed attempt to re-implementcomposer/semverin Go. It only supports a subset of Composer versioning.
Credits
Composer SemVer is a Typist Tech project and maintained by Tang Rufus, freelance developer for hire.
Full list of contributors can be found on GitHub.
Copyright and License
This project is a free software distributed under the terms of the MIT license. For the full license, see LICENSE.
Contribute
Feedbacks / bug reports / pull requests are welcome.
typisttech/composer-semver 适用场景与选型建议
typisttech/composer-semver 是一款 基于 Go 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cli」 「composer」 「validation」 「semver」 「versioning」 「semantic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 typisttech/composer-semver 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 typisttech/composer-semver 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 typisttech/composer-semver 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Adds request-parameter validation to the SLIM 3.x PHP framework
A jQuery augmented PHP library for creating and validating HTML forms
Simple ASCII output of array data
A Laravel validator for delimiter-separated list of emails.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-11