本文整理汇总了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;
}
示例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", "----------------------------------------------------------------------------", ""]);
}
示例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;
}