Helper function to get a current version from composer.json
file in your project
If you want to get separate values of major/minor/patch version, you can try mazanax/composer-version-semver
composer require mazanax/composer-project-version
<?php
$packageVersion = \MZNX\ComposerPackageVersion\PackageVersion::init(__DIR__ . '/path/to/composer.json');
$version = $packageVersion->getVersion();
$packageVersion = \MZNX\ComposerPackageVersion\Version(__DIR__ . '/path/to/composer.json');
MIT