Skip to content

An independent implementation of composer's versions constraints parser.

Notifications You must be signed in to change notification settings

PHPExpertsInc/ComposerConstraintsParser

Repository files navigation

Composer Constraints Parser

Composer Constraints Parser is a PHP Experts, Inc., Project that is a clean-room implementation of Packagist's composer's version constraint system.

It is meant as a zero-dependency option to faithfully interpret whether any particular version number is satisfiable by a composer verison constraint.

NOTE: 95% of this code was generated by the autonomous AI agents of Autonomo, by Autonomous Programming, LLC. See https://gist.github.com/hopeseekr/fdb0ff9bd0957ea8d226ccc2def88d99

This project contains 100% of all of the in-the-world composer version constraints of every dependency of every package in the entire packagist.org database. These can be found in [tests/constraints.json].

There are 155,623 test assertions testing all 48,209 in-the-wild composer version constraints and has 100% fidelity. It is current as of 2025-04-01.

This is possible because of the Bettergist Collector API, which archives every PHP packagist package weekly and does deep analysis of them quarterly.

Installation

Via Composer

composer require phpexperts/composer-version-parser

Usage

use PHPExperts\ComposerVersionConstraints\ComposerConstraintsHelper;

$satisfies = ComposerConstraintsHelper::versionSatisfies('7.4', '^7.4|^8.0');
// true

Use cases

✔ Can determine if a constraint is valid
✔ Complex composer constraints
✔ All composer constraints
✔ Known constraint

Testing

phpunit

Contributors

Theodore R. Smith theodore@phpexperts.pro
GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
CEO: PHP Experts, Inc.

License

MIT license. Please see the license file for more information.

About

An independent implementation of composer's versions constraints parser.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages