This is a simple command-line tool built with PHP that helps you work with SemVer (Semantic Versioning) strings. You can use it to check if a version string is valid, compare two versions to see which one is greater, or increase a version by major, minor, or patch levels.
- PHP 7.4 or higher
- Composer
You can install it globally or locally using Composer:
composer global require syntatis/version-cliOr, use as a development dependency in your project:
composer require --dev syntatis/version-cliIf you run it globally, you can use the version command directly in your terminal:
version --helpIf you installed it locally in your project, run it using the vendor binary:
vendor/bin/version --helpThe command provides several options to work with version strings:
| Command | Description | Usage |
|---|---|---|
validate |
Validates the given version string against the SemVer specification. | version validate 1.0.0 |
increment |
Increments the version string by major, minor, or patch. | version increment 1.0.0 |
gt |
Compares two version strings to see if the first is greater than the second. | version gt 1.0.0 0.9.0 |
lt |
Compares two version strings to see if the first is less than the second. | version lt 1.0.0 0.9.0 |
eq |
Compares two version strings to see if they are equal. | version eq 1.0.0 1.0.0 |
The command supports both patterns with or without the v prefix, so you can use 1.0.0 or v1.0.0. For more details on each command, you can run:
version list