Reputation: 7318
Is there a way to get the current version of slim? Like a php code expression or such that would display the real version the script is currently running?
Upvotes: 3
Views: 105
Reputation: 11135
You can parse the composer.lock
-file to get the version of that dependency.
$composerLock = json_decode(file_get_contents('composer.lock'));
foreach($composerLock->packages as $package) {
if ($package->name == 'slim/slim') {
$version = $package->version;
break;
}
}
echo $version;
In slim there is also a VERSION
-constant on the App
(v3.x) or Slim
(v2.x) class
// 2.x
$app = \Slim\Slim;
$version = \Slim\Slim::VERSION;
// 3.x
$app = \Slim\App;
$version = \Slim\App::VERSION;
Upvotes: 2