public static function findBin($bin)
{
$path = getenv('PATH');
$paths = explode(PATH_SEPARATOR, $path);
foreach ($paths as $path) {
$f = $path . DIRECTORY_SEPARATOR . $bin;
// realpath will handle file existence or symbolic link automatically
$f = realpath($f);
if ($f !== false) {
return $f;
}
}
return;
}