mazanax / composer-version-semver
Small helper to get current composer project version
1.0.0
2021-04-20 09:15 UTC
Requires
- php: ^7.4|^8.0
- ext-json: *
- mazanax/composer-project-version: ^1.0.0
- nikolaposa/version: ^4.1
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-10-20 18:33:26 UTC
README
Composer Package Version
Helper class to get a current version from composer.json
file in your project
If you want to get only string version, you can use mazanax/composer-project-version
Installation
composer require mazanax/composer-version-semver
Usage
• Accessing Major/Minor/Patch version
<?php $packageVersion = \MZNX\ComposerPackageSemver\PackageVersionSemver::init(__DIR__ . '/path/to/composer.json'); $version = $packageVersion->getVersion(); echo $version->getMajor() . PHP_EOL; echo $version->getMinor() . PHP_EOL; echo $version->getPatch() . PHP_EOL;
• Getting version as string
<?php $packageVersion = \MZNX\ComposerPackageSemver\PackageVersionSemver::init(__DIR__ . '/path/to/composer.json'); $version = $packageVersion->getVersionAsString(); echo $version . PHP_EOL;
License
MIT