当前位置: 首页>>代码示例>>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;未经允许,请勿转载。