mazanax/composer-version-semver

Small helper to get current composer project version

1.0.0 2021-04-20 09:15 UTC

This package is auto-updated.

Last update: 2022-07-20 13:43:14 UTC


README

Minimum PHP Version Latest Stable Version Build Status codecov

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