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


PHP ProcessBuilder::addEnvironmentVariables方法代碼示例

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


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

示例1: createProcessBuilder

 /**
  * Create process builder object
  *
  * @param array $arguments
  *
  * @return ProcessBuilder
  */
 protected function createProcessBuilder(array $arguments = [])
 {
     $processBuilder = new ProcessBuilder($arguments);
     $processBuilder->setPrefix($this->getOption('bin', self::DEFAULT_BINARY));
     $processBuilder->addEnvironmentVariables($this->getOption('env', []));
     return $processBuilder;
 }
開發者ID:etd-framework,項目名稱:Ghostscript,代碼行數:14,代碼來源:Ghostscript.php

示例2: _reconfigure

 /**
  * {@inheritDoc}
  *
  * Starts the connection
  */
 public function _reconfigure($config = array())
 {
     parent::_reconfigure($config);
     if (!isset($this->config['username'])) {
         throw new \Exception("Sauce Connect Extension requires a username.");
     }
     if (!isset($this->config['accesskey'])) {
         throw new \Exception("Sauce Connect Extension requires a accesskey.");
     }
     $connect = __DIR__ . '/../../../bin/sauce_connect';
     if (!file_exists($connect)) {
         $connect = __DIR__ . '/../../../../bin/sauce_connect';
     }
     if (!file_exists($connect)) {
         throw new \Exception("Couldnt find the bin directory... Make sure its in ./bin or ./vendor/bin/");
     }
     $processBuilder = new ProcessBuilder([$connect]);
     $processBuilder->addEnvironmentVariables(['SAUCE_USERNAME' => $this->config['username'], 'SAUCE_ACCESS_KEY' => $this->config['accesskey']]);
     $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 60;
     $this->process = $processBuilder->getProcess();
     $this->process->setTimeout(0);
     $this->process->start(function ($type, $buffer) {
         $buffer = explode("\n", $buffer);
         foreach ($buffer as $line) {
             if (strpos($line, 'Press any key to see more output') === false) {
                 file_put_contents(codecept_output_dir() . 'sauce_connect.log', $line . "\n", FILE_APPEND);
             }
         }
     });
     $timer = 0;
     $connected = false;
     $this->writeln(["", "----------------------------------------------------------------------------", "Attempting to connect to SauceLabs. Waiting {$timeout} seconds."]);
     while ($this->process->isRunning() && $timer < $timeout) {
         $output = $this->process->getOutput();
         if (strpos($output, 'Connected! You may start your tests.') !== false) {
             $connected = true;
             break;
         }
         sleep(1);
         $timer++;
         if ($timer % 5 === 0) {
             $this->write('.');
         }
     }
     if (false === $connected) {
         $this->process->stop();
         throw new \Exception(sprintf("Could not start tunnel. Check %ssauce_connect.log for more information.", codecept_output_dir()));
     }
     $this->writeln(["", "Connected to SauceLabs", "----------------------------------------------------------------------------", ""]);
 }
開發者ID:lfgamers,項目名稱:sauce-connect-extension,代碼行數:55,代碼來源:SauceConnectExtension.php

示例3: addEnvironmentVariables

 /**
  * Adds a set of environment variables.
  *
  * Already existing environment variables with the same name will be
  * overridden by the new values passed to this method. Pass `null` to unset
  * a variable.
  *
  * @param array $variables The variables
  *
  * @return ProcessBuilderProxyInterface
  */
 public function addEnvironmentVariables(array $variables) : ProcessBuilderProxyInterface
 {
     $this->processBuilder->addEnvironmentVariables($variables);
     return $this;
 }
開發者ID:gplanchat,項目名稱:grenade,代碼行數:16,代碼來源:ProcessBuilderProxyTrait.php


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