Skip to content

Instantly share code, notes, and snippets.

@chitoku-k
Last active August 28, 2015 15:24
Show Gist options
  • Save chitoku-k/52b8598105f5be64b9e9 to your computer and use it in GitHub Desktop.
Save chitoku-k/52b8598105f5be64b9e9 to your computer and use it in GitHub Desktop.
<?php
function GetVersion($command, $pattern = '/([\d.]*[\d])/') {
if (preg_match($pattern, shell_exec($command), $matches)) {
return $matches[1];
}
return false;
}
$versions = [
'php' => phpversion(),
'node' => GetVersion('node --version'),
'npm' => GetVersion('npm --version'),
'linux' => GetVersion('cat /proc/version'),
'mysql' => GetVersion('mysql --version'),
'openssl' => GetVersion('openssl version', '/(\d[\d.a-z]+)/'),
'apache' => GetVersion('apachectl -v'),
'ruby' => GetVersion('ruby --version'),
'curl' => GetVersion('curl --version'),
];
foreach ($versions as $app => $ver) {
echo $app . ': ' . $ver . '<br>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment