PhpBrew\Utils::system PHP Method

system() public static method

public static system ( $command, $logger = null, $build = null )
    public static function system($command, $logger = null, $build = null)
    {
        if (is_array($command)) {
            $command = implode(' ', $command);
        }
        if ($logger) {
            $logger->debug('Running Command:' . $command);
        }
        $lastline = system($command, $returnValue);
        if ($returnValue !== 0) {
            throw new SystemCommandException("Command failed: {$command} returns: {$lastline}", $build);
        }
        return $returnValue;
    }

Usage Example

示例#1
0
 protected function process($url, $targetFilePath)
 {
     $this->logger->info('downloading via curl command');
     //todo proxy setting
     $silent = $this->logger->isQuiet() ? '--silent ' : '';
     $command = array('curl');
     if ($proxy = $this->options->{'http-proxy'}) {
         $this->logger->warn('http proxy is not support by this download.');
     }
     if ($proxyAuth = $this->options->{'http-proxy-auth'}) {
         $this->logger->warn('http proxy is not support by this download.');
     }
     if ($this->enableContinueAt || $this->options->{'continue'}) {
         $command[] = '-C -';
     }
     $command[] = '-L';
     if ($this->logger->isQuiet()) {
         $command[] = '--silent';
     }
     $command[] = '-o';
     $command[] = escapeshellarg($targetFilePath);
     $command[] = escapeshellarg($url);
     $cmd = implode(' ', $command);
     $this->logger->debug($cmd);
     Utils::system($cmd);
     return true;
 }
All Usage Examples Of PhpBrew\Utils::system