當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Process::enableOutput方法代碼示例

本文整理匯總了PHP中Symfony\Component\Process\Process::enableOutput方法的典型用法代碼示例。如果您正苦於以下問題:PHP Process::enableOutput方法的具體用法?PHP Process::enableOutput怎麽用?PHP Process::enableOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Process\Process的用法示例。


在下文中一共展示了Process::enableOutput方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: shell

 public static function shell($commands, array $opts = [])
 {
     //$cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array()
     if (is_array($commands)) {
         $procs = [];
         foreach ($commands as $command) {
             $procs[] = static::shell($command, $opts);
         }
         return $procs;
     }
     $process = new Process($commands);
     $options = array_replace(['type' => 'sync', 'cwd' => null, 'env' => null, 'timeout' => 60, 'callback' => null, 'output' => true], $opts);
     $options['cwd'] !== null && $process->setWorkingDirectory($options['cwd']);
     $options['env'] !== null && $process->setEnv($options['env']);
     is_int($options['timeout']) && $process->setTimeout($options['timeout']);
     if ($options['output'] === true) {
         $process->enableOutput();
     } else {
         $process->disableOutput();
     }
     $type = $options['type'];
     if ($type === 'sync') {
         $process->run($options['callback']);
     } elseif ($type === 'async') {
         $process->start();
     }
     return $process;
 }
開發者ID:laradic,項目名稱:support,代碼行數:28,代碼來源:Util.php

示例2: execute

 /**
  * @param $command
  */
 public function execute($command)
 {
     $cwd = getcwd();
     chdir($this->currentWorkingDirectory);
     $process = new Process($command);
     $process->enableOutput();
     $process->run();
     if (!$process->isSuccessful()) {
         chdir($cwd);
         throw new ProcessException($process->getErrorOutput());
     }
     chdir($cwd);
 }
開發者ID:genkgo,項目名稱:srvcleaner,代碼行數:16,代碼來源:Processor.php

示例3: getCurrentGitUser

 /**
  * Get the current git user information. We need this to extract
  * the user name and email to put into the generated files
  * @return mixed
  */
 private function getCurrentGitUser()
 {
     $p = new Process('git config --list');
     $p->enableOutput();
     $result = [];
     try {
         $p->mustRun();
         $lines = explode("\n", trim($p->getOutput()));
         foreach ($lines as $line) {
             $ar = explode('=', trim($line));
             if (count($ar) === 2) {
                 $result[$ar[0]] = $ar[1];
             }
         }
         return $result;
     } catch (\Exception $e) {
         $user = get_current_user();
         return array('user.name' => $user, 'user.email' => $user);
     }
 }
開發者ID:blendsdk,項目名稱:blendengine,代碼行數:25,代碼來源:InitCommand.php


注:本文中的Symfony\Component\Process\Process::enableOutput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。