本文整理汇总了PHP中Symfony\Component\Process\ProcessBuilder::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP ProcessBuilder::setOption方法的具体用法?PHP ProcessBuilder::setOption怎么用?PHP ProcessBuilder::setOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\ProcessBuilder
的用法示例。
在下文中一共展示了ProcessBuilder::setOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeProcess
public function executeProcess($output, $processArguments, $file, $prefixes, $postfixes, $arguments, $options)
{
foreach ($prefixes as $prefix) {
$processArguments[] = $prefix;
}
$processArguments[] = $file;
foreach ($postfixes as $postfix) {
$processArguments[] = $postfix;
}
$processBuilder = new ProcessBuilder($processArguments);
foreach ($arguments as $argument) {
$processBuilder->add($argument);
}
foreach ($options as $optionName => $optionValue) {
$processBuilder->setOption($optionName, $optionValue);
}
$process = $processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
$output->writeln(sprintf('<error>%s</error>', trim($process->getErrorOutput())));
}
if ($process->getOutput()) {
$output->writeln($process->getOutput());
}
return $process;
}
示例2: setOption
/**
* Adds a proc_open option.
*
* @param string $name The option name
* @param string $value The option value
*
* @return ProcessBuilderProxyInterface
*/
public function setOption(string $name, string $value) : ProcessBuilderProxyInterface
{
$this->processBuilder->setOption($name, $value);
return $this;
}
示例3: analyzer
private function analyzer($output, $analyzer, $files, $config)
{
$enabled = $config->get('application.analyzer.' . $analyzer . '.enabled');
if (!$enabled) {
return;
}
$exception = $config->get('application.analyzer.' . $analyzer . '.exception');
$options = $config->get('application.analyzer.' . $analyzer . '.options');
$arguments = $config->get('application.analyzer.' . $analyzer . '.arguments');
if ($arguments) {
$arguments = array_keys($arguments);
}
$success = true;
$this->validateBinary('bin/' . $analyzer);
$output->writeln(sprintf('<info>%s</info>', $config->get('application.messages.' . $analyzer . '.info')));
foreach ($files as $file) {
if (!preg_match($this->needle, $file) && !is_dir(realpath($this->directory . $file))) {
continue;
}
$arguments[] = $file;
$processBuilder = new ProcessBuilder(['php', $this->directory . 'bin/' . $analyzer]);
if ($arguments) {
foreach ($arguments as $argument) {
$processBuilder->add($argument);
}
}
if ($options) {
foreach ($options as $optionName => $optionValue) {
$processBuilder->setOption($optionName, $optionValue);
}
}
$process = $processBuilder->getProcess();
$process->run();
if (!$process->isSuccessful()) {
$output->writeln(sprintf('<error>%s</error>', trim($process->getErrorOutput())));
$success = false;
}
$output->writeln(sprintf('<comment>%s</comment>', trim($process->getOutput())));
}
if ($exception && !$success) {
throw new \Exception($config->get('application.messages.' . $analyzer . '.error'));
}
}