Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/einenlum/composer-version-parser
A library to extract the potential higher version of a package from Composer requirements
https://github.com/einenlum/composer-version-parser
composer php semver
Last synced: about 7 hours ago
JSON representation
A library to extract the potential higher version of a package from Composer requirements
- Host: GitHub
- URL: https://github.com/einenlum/composer-version-parser
- Owner: Einenlum
- License: mit
- Created: 2023-10-13T13:09:51.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-13T18:17:41.000Z (about 1 year ago)
- Last Synced: 2024-11-08T13:43:15.370Z (about 9 hours ago)
- Topics: composer, php, semver
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Composer Version Parser
This small library allows to parse the version requirements from a `composer.json` file, allowing to get the probable version of a package (useful when no `composer.lock` is present).
Examples:
| Input | Output |
| -- | -- |
| `v1.0.*` | `1.0` |
| `1.0.*` | `1.0` |
| `^3.*` | `3` |
| `^3.4.*` | `3.4` |
| `^3.4` | `3` |
| `^3.4.9` | `3.4` |
| `~3` | `3` |
| `~3.4` | `3` |
| `~3.4.9` | `3.4` |
| `3` | `3` |
| `3.4` | `3.4` |
| `3.4.9` | `3.4.9` |
| `3.*` | `3` |
| `3.4.*` | `3.4` |
| `v3` | `3` |
| `v3.4` | `3.4` |
| `v3.4.9` | `3.4.9` |
| `v3.*` | `3` |
| `v3.4.*` | `3.4` |
| `*` | `null` |More complex cases are not handled for now.
| Input | Output |
| -- | -- |
| `>1.0.*` | `null` |
| `>=1.0` | `null` |
|>=1.0 || 8.*
| `null` |
| `>=1.0; <2.0` | `null` |## Install
```
composer require einenlum/composer-version-parser
```## Usage
```php
parse('v3.4.*'); // '3.4'
```