How do I make a script there can tell me what version i run when it stored in composer.json?
composer.json
{
"require": {
"someLiberyNameHere": "8.3.3.1"
}
}
How do I make a script there can tell me what version i run when it stored in composer.json?
composer.json
{
"require": {
"someLiberyNameHere": "8.3.3.1"
}
}
I think that this is as simple as this since composer.json is a Json file:
<?php
$content = file_get_contents('/path/to/composer.json');
$content = json_decode($content,true);
var_dump($content['require']['someLiberyNameHere']);
You can also iterate through your dependencies:
foreach ($content['require'] as $key => $value) {
echo $key . ' => ' . $value . PHP_EOL;
}
\Composer\InstalledVersions::getRootPackage();
\Composer\InstalledVersions::getVersion('vendor/package');
https://getcomposer.org/doc/07-runtime.md#installed-versions
You can make composer object from factory And find your package in repository and give package info.
© 2022 - 2024 — McMap. All rights reserved.