PhpBrew\Utils::findBin PHP Method

findBin() public static method

Find executable binary by PATH environment.
public static findBin ( string $bin ) : string
$bin string binary name
return string the path
    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;
    }

Usage Example

Exemplo n.º 1
0
 protected function detectProcessorNumberByGrep()
 {
     if (Utils::findBin('grep') && file_exists('/proc/cpuinfo')) {
         $process = new Process('grep -c ^processor /proc/cpuinfo 2>/dev/null');
         $process->run();
         $this->processorNumber = intval($process->getOutput());
         return $this->processorNumber;
     }
     return null;
 }
All Usage Examples Of PhpBrew\Utils::findBin