arkuuu / semantic-version
A small tool to handle semantic versions and their comparison
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/arkuuu/semantic-version
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^8.3.3
- squizlabs/php_codesniffer: ^3.4
README
A small PHP library to handle semantic versions and compare them to each other.
This is a small library with restricted real life use. I mainly created it to practice unit testing, github actions and publishing to packagist. If you really need a library like this, try Composer\Semver.
Installation
Use composer to install from packagist.
composer require arkuuu/semantic-version
Usage
$currentVersion = new Version('1.0.17'); $minimalVersion = new Version('1.0'); $versionOk = $currentVersion->isGreaterOrEqual($minimalVersion); // $versionOk will be "true" $versionA = new Version('1.0.17'); $versionB = new Version('1.0.25'); $sameVersions = $versionA->isSame($versionB); // $sameVersions will be "false"
Ideas for the future
- Refactor comparisons into own class
- Support check against version constraints (^,~etc)
- Support wildcards (e.g. 1.4.*)
- Support more comparisons (e.g. less than)