当前位置: 首页>>代码示例>>PHP>>正文


PHP Process::setWorkingDirectory方法代码示例

本文整理汇总了PHP中Symfony\Component\Process\Process::setWorkingDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::setWorkingDirectory方法的具体用法?PHP Process::setWorkingDirectory怎么用?PHP Process::setWorkingDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Process\Process的用法示例。


在下文中一共展示了Process::setWorkingDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: iRunBehat

 /**
  * Runs behat command with provided parameters
  *
  * @When /^I run "behat(?: ([^"]*))?"$/
  *
  * @param   string $argumentsString
  */
 public function iRunBehat($argumentsString = '')
 {
     $argumentsString = strtr($argumentsString, array('\'' => '"'));
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $argumentsString, strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"'))));
     $this->process->run();
 }
开发者ID:AntonKalachev,项目名称:ChainedStepsExtension,代码行数:14,代码来源:FeatureContext.php

示例2: iRunBehat

 /**
  * @When /^I run behat$/
  */
 public function iRunBehat()
 {
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"')), '--format=progress'));
     $this->process->start();
     $this->process->wait();
 }
开发者ID:icambridge,项目名称:BehatPageObjectExtension,代码行数:10,代码来源:BehatRunnerContext.php

示例3: execute

 public function execute()
 {
     $logger = $this->getRunConfig()->getLogger();
     $this->process = new Process($this->command);
     $logger->info('Start command:' . $this->command);
     $this->process->setTimeout($this->timeout);
     $this->process->setWorkingDirectory($this->getRunConfig()->getRepositoryDirectory());
     $this->process->run();
     $output = trim($this->process->getOutput());
     $logger->info($output);
     if (!$this->process->isSuccessful()) {
         $logger->emergency($this->process->getErrorOutput());
         throw new \RuntimeException('Command not successful:' . $this->command);
     }
 }
开发者ID:funivan,项目名称:ci,代码行数:15,代码来源:ShellCommand.php

示例4: doRunBehat

 /**
  * @param string $configurationAsString
  */
 private function doRunBehat($configurationAsString)
 {
     $this->process->setWorkingDirectory($this->testApplicationDir);
     $this->process->setCommandLine(sprintf('%s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $configurationAsString));
     $this->process->start();
     $this->process->wait();
 }
开发者ID:Canu667,项目名称:todoapp,代码行数:10,代码来源:FeatureContext.php

示例5: 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

示例6: render

 function render($context = null, $vars = array())
 {
     $options = $this->options;
     $compress = @$options["compress"] ?: false;
     $outputFile = tempnam(sys_get_temp_dir(), 'metatemplate_template_less_output');
     $finder = new ExecutableFinder();
     $bin = @$this->options["less_bin"] ?: self::DEFAULT_LESSC;
     $cmd = $finder->find($bin);
     if ($cmd === null) {
         throw new \UnexpectedValueException("'{$bin}' executable was not found. Make sure it's installed.");
     }
     if ($compress) {
         $cmd .= ' -x';
     }
     if (array_key_exists('include_path', $this->options)) {
         $cmd .= sprintf('--include-path %s', escapeshellarg(join(PATH_SEPARATOR, (array) $this->options['include_path'])));
     }
     $cmd .= " --no-color - {$outputFile}";
     $process = new Process($cmd);
     $process->setStdin($this->getData());
     if ($this->isFile()) {
         $process->setWorkingDirectory(dirname($this->source));
     }
     $process->setEnv(array('PATH' => getenv("PATH")));
     $process->run();
     $content = @file_get_contents($outputFile);
     @unlink($outputFile);
     if (!$process->isSuccessful()) {
         throw new \RuntimeException("{$cmd} returned an error: " . $process->getErrorOutput());
     }
     return $content;
 }
开发者ID:chh,项目名称:meta-template,代码行数:32,代码来源:LessTemplate.php

示例7: createProcess

 public function createProcess($command)
 {
     //echo ": $command\n";
     $process = new Process($command);
     $process->setWorkingDirectory($this->repoDirectory);
     return $process;
 }
开发者ID:micaherne,项目名称:moodle-deconstruct,代码行数:7,代码来源:Git.php

示例8: runCommand

 /**
  * Runs the given string as a command and returns the resulting output.
  * The CWD is set to the root project directory to simplify command paths.
  *
  * @param string $command
  *
  * @return string
  *
  * @throws ProcessFailedException in case the command execution is not successful
  */
 private function runCommand($command, $workingDirectory = null)
 {
     $process = new Process($command);
     $process->setWorkingDirectory($workingDirectory ?: $this->rootDir);
     $process->mustRun();
     return $process->getOutput();
 }
开发者ID:slavomirkuzma,项目名称:symfony-installer,代码行数:17,代码来源:IntegrationTest.php

示例9: run

 public function run()
 {
     $command = $this->getCommand();
     $dir = $this->workingDirectory ? " in " . $this->workingDirectory : "";
     $this->printTaskInfo("Running <info>{$command}</info>{$dir}");
     $this->process = new Process($command);
     $this->process->setTimeout($this->timeout);
     $this->process->setIdleTimeout($this->idleTimeout);
     $this->process->setWorkingDirectory($this->workingDirectory);
     if (isset($this->env)) {
         $this->process->setEnv($this->env);
     }
     if (!$this->background and !$this->isPrinted) {
         $this->startTimer();
         $this->process->run();
         $this->stopTimer();
         return new Result($this, $this->process->getExitCode(), $this->process->getOutput(), ['time' => $this->getExecutionTime()]);
     }
     if (!$this->background and $this->isPrinted) {
         $this->startTimer();
         $this->process->run(function ($type, $buffer) {
             print $buffer;
         });
         $this->stopTimer();
         return new Result($this, $this->process->getExitCode(), $this->process->getOutput(), ['time' => $this->getExecutionTime()]);
     }
     try {
         $this->process->start();
     } catch (\Exception $e) {
         return Result::error($this, $e->getMessage());
     }
     return Result::success($this);
 }
开发者ID:stefanhuber,项目名称:Robo,代码行数:33,代码来源:Exec.php

示例10: checkPatch

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return bool|null
  *   TRUE is patch applies, FALSE if patch does not, and NULL if something
  *   else occurs.
  */
 protected function checkPatch(InputInterface $input, OutputInterface $output)
 {
     $issue = $this->getIssue($input->getArgument('url'));
     if ($issue) {
         $patch = $this->choosePatch($issue, $input, $output);
         if ($patch) {
             $patch = $this->getPatch($patch);
             $this->verbose($output, "Checking {$patch} applies");
             $repo_dir = $this->getConfig()->getDrupalRepoDir();
             $this->ensureLatestRepo($repo_dir);
             $process = new Process("git apply --check {$patch}");
             $process->setWorkingDirectory($repo_dir);
             $process->run();
             if ($process->isSuccessful()) {
                 $this->output = $process->getOutput();
                 return TRUE;
             } else {
                 $this->output = $process->getErrorOutput();
                 return FALSE;
             }
         }
     }
     // There is no patch, or there is a problem getting the issue.
     return NULL;
 }
开发者ID:joelpittet,项目名称:dopatchutils,代码行数:32,代码来源:ValidatePatch.php

示例11: render

 function render($context = null, $vars = array())
 {
     $finder = new ExecutableFinder();
     $bin = @$this->options["tsc_bin"] ?: self::DEFAULT_TSC;
     $cmd = $finder->find($bin);
     if ($cmd === null) {
         throw new \UnexpectedValueException("'{$bin}' executable was not found. Make sure it's installed.");
     }
     $inputFile = sys_get_temp_dir() . '/pipe_typescript_input_' . uniqid() . '.ts';
     file_put_contents($inputFile, $this->getData());
     $outputFile = tempnam(sys_get_temp_dir(), 'pipe_typescript_output_') . '.js';
     $cmd .= " --out " . escapeshellarg($outputFile) . ' ' . escapeshellarg($inputFile);
     $process = new Process($cmd);
     $process->setEnv(array('PATH' => @$_SERVER['PATH'] ?: join(PATH_SEPARATOR, array("/bin", "/sbin", "/usr/bin", "/usr/local/bin", "/usr/local/share/npm/bin"))));
     if ($this->isFile()) {
         $process->setWorkingDirectory(dirname($this->source));
     }
     $process->run();
     unlink($inputFile);
     if ($process->getErrorOutput()) {
         throw new \RuntimeException("tsc({$this->source}) returned an error:\n {$process->getErrorOutput()}");
     }
     $data = file_get_contents($outputFile);
     unlink($outputFile);
     return $data;
 }
开发者ID:chh,项目名称:meta-template,代码行数:26,代码来源:TypeScriptTemplate.php

示例12: run

 /**
  * {@inheritdoc}
  */
 public function run()
 {
     $this->printAction();
     $this->process = new Process($this->getCommand());
     $this->process->setTimeout($this->timeout);
     $this->process->setIdleTimeout($this->idleTimeout);
     $this->process->setWorkingDirectory($this->workingDirectory);
     if (isset($this->env)) {
         $this->process->setEnv($this->env);
     }
     if (!$this->background and !$this->isPrinted) {
         $this->startTimer();
         $this->process->run();
         $this->stopTimer();
         return new Result($this, $this->process->getExitCode(), $this->process->getOutput(), ['time' => $this->getExecutionTime()]);
     }
     if (!$this->background and $this->isPrinted) {
         $this->startTimer();
         $this->process->run(function ($type, $buffer) {
             $progressWasVisible = $this->hideTaskProgress();
             print $buffer;
             $this->showTaskProgress($progressWasVisible);
         });
         $this->stopTimer();
         return new Result($this, $this->process->getExitCode(), $this->process->getOutput(), ['time' => $this->getExecutionTime()]);
     }
     try {
         $this->process->start();
     } catch (\Exception $e) {
         return Result::fromException($this, $e);
     }
     return Result::success($this);
 }
开发者ID:jjok,项目名称:Robo,代码行数:36,代码来源:Exec.php

示例13: run

 public function run()
 {
     $command = $this->getCommand();
     $dir = $this->workingDirectory ? " in " . $this->workingDirectory : "";
     $this->printTaskInfo("running <info>{$command}</info>{$dir}");
     $this->process = new Process($command);
     $this->process->setTimeout($this->timeout);
     $this->process->setIdleTimeout($this->idleTimeout);
     $this->process->setWorkingDirectory($this->workingDirectory);
     if (!$this->background and !$this->isPrinted) {
         $this->process->run();
         return new Result($this, $this->process->getExitCode(), $this->process->getOutput());
     }
     if (!$this->background and $this->isPrinted) {
         $this->process->run(function ($type, $buffer) {
             Process::ERR === $type ? print 'ER» ' . $buffer : (print '» ' . $buffer);
         });
         return new Result($this, $this->process->getExitCode(), $this->process->getOutput());
     }
     try {
         $this->process->start();
     } catch (\Exception $e) {
         return Result::error($this, $e->getMessage());
     }
     return Result::success($this);
 }
开发者ID:sliver,项目名称:Robo,代码行数:26,代码来源:Exec.php

示例14: iRunBehat

 /**
  * Runs Behat with provided parameters.
  *
  * @When /^I run "behat(?: ((?:\"|[^"])*))?"$/
  *
  * @param string $argumentsString
  */
 public function iRunBehat($argumentsString = '')
 {
     $argumentsString = strtr($argumentsString, ['\'' => '"']);
     $this->behatProcess->setWorkingDirectory($this->workingDir);
     $this->behatProcess->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), $argumentsString, strtr('--format-settings=\'{"timer": false}\' --no-colors', ['\'' => '"', '"' => '\\"'])));
     $this->behatProcess->start();
     $this->behatProcess->wait();
 }
开发者ID:elifesciences,项目名称:isolated-drupal-behat-extension,代码行数:15,代码来源:FeatureContext.php

示例15: iRunPhpspec

 /**
  * Runs phpspec command with provided parameters
  *
  * @When /^I run "phpspec(?: ((?:\"|[^"])*))?"$/
  *
  * @param string $argumentsString
  */
 public function iRunPhpspec($argumentsString = '')
 {
     $argumentsString = strtr($argumentsString, array('\'' => '"'));
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s --no-interaction', $this->phpBin, escapeshellarg($this->getPhpspecBinPath()), $argumentsString));
     $this->process->start();
     $this->process->wait();
 }
开发者ID:codifico,项目名称:phpspec-rest-view-extension,代码行数:15,代码来源:FeatureContext.php


注:本文中的Symfony\Component\Process\Process::setWorkingDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。