本文整理汇总了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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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;
}
示例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;
}
示例7: createProcess
public function createProcess($command)
{
//echo ": $command\n";
$process = new Process($command);
$process->setWorkingDirectory($this->repoDirectory);
return $process;
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}