composer/semver
A standalone PHP library for parsing, validating, and comparing semantic version numbers and constraints, extracted from Composer. It normalizes versions, handles stability flags and branches, and powers dependency version checks. Requires PHP 5.3.2+.
VersionParser::isValid() gives a first-class, one-call API to answer "is this a valid/normalizable version string?" — directly serves user-facing validation (manifest uploads, plugin submission forms, upgrade pre-flight checks) without custom guard code> 1.0.0 != 2.0.0 || < 1.9.0 into != 2.0.0 (which wrongly matched all dev-* versions), and >=/< on RC versions no longer picks up a spurious -dev suffix — both improve trust in any "is this upgrade safe?" surface we shipCompilingMatcher performance improvement lowers per-call overhead in hot paths (bulk constraint matching across a registry), improving responsiveness of large compatibility scans^1.2.3, or compare versions with stability flags (e.g., 1.0.0-beta)isValid() (3.5.0+) lets us reject malformed input with a supported API rather than try/catch around normalizationdev-* versions, branch aliases, or RC/alpha/beta boundaries — 3.5.0 fixes correctness here, so pin to ^3.5 rather than older 3.xExecutives: "This MIT-licensed package is the industry standard for version handling in PHP, used by Composer itself. It eliminates the risk and cost of building custom version logic, ensuring accurate dependency resolution and reducing time-to-market for features like plugin compatibility checks. With 3,287 GitHub stars and active maintenance, it's battle-tested and zero-risk for our product. The 3.5.0 release is a low-risk minor upgrade — no breaking changes — that adds a direct 'is this version valid?' API for user-facing validation and fixes two correctness bugs in constraint handling around dev and RC versions, which means fewer wrong compatibility answers to customers."
Engineering: "Lightweight, battle-tested library with robust CI/CD and tests. 3.5.0 is a drop-in minor bump: no deprecations or breaking changes, so it's a low-effort composer update. It gives us VersionParser::isValid() for input validation without hand-rolled try/catch, fixes Intervals::compactConstraint() incorrectly collapsing constraints into != 2.0.0 (which matched all dev-* versions), and fixes >=/< on RC versions picking up an unwanted -dev suffix. CompilingMatcher also avoids rebuilding concatenated cache keys per call, so bulk matching gets faster for free. Recommend constraining to ^3.5 so we get these fixes; regression-test any code that relied on the old (buggy) compaction output. PHPStan and PHPUnit coverage guarantees code quality."
How can I help you explore Laravel packages today?