An open API service indexing awesome lists of open source software.

https://github.com/phpexpertsinc/composerconstraintsparser

An independent implementation of composer's versions constraints parser.
https://github.com/phpexpertsinc/composerconstraintsparser

Last synced: 4 months ago
JSON representation

An independent implementation of composer's versions constraints parser.

Awesome Lists containing this project

README

          

# 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

```bash
composer require phpexperts/composer-version-parser
```

## Usage

```php
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

```bash
phpunit
```

## Contributors

[Theodore R. Smith](https://www.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](LICENSE) for more information.