本文整理汇总了PHP中Symfony\Component\Process\Process::getEnv方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::getEnv方法的具体用法?PHP Process::getEnv怎么用?PHP Process::getEnv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Process\Process
的用法示例。
在下文中一共展示了Process::getEnv方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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('\'' => '"', '"' => '\\"'))));
// Don't reset the LANG variable on HHVM, because it breaks HHVM itself
if (!defined('HHVM_VERSION')) {
$env = $this->process->getEnv();
$env['LANG'] = 'en';
// Ensures that the default language is en, whatever the OS locale is.
$this->process->setEnv($env);
}
$this->process->start();
$this->process->wait();
}
示例2: compileProcess
protected function compileProcess(Process $process, $path)
{
$process->setEnv(['PATH' => implode(':', array_merge($this->paths, [trim(`echo \$PATH`)]))]);
$out = '';
$err = '';
$status = $process->run(function ($type, $line) use(&$out, &$err) {
if ($type === 'out') {
$out .= $line . PHP_EOL;
} else {
if ($type === 'err') {
$err .= $line . PHP_EOL;
}
}
});
if ($status === 0) {
return $out;
} else {
throw new CompilationException($path, $err, ['path' => $process->getEnv()['PATH'], 'time' => date('Y-m-d H:i T'), 'command' => $process->getCommandLine()]);
}
}
示例3: process
/**
* Gets the path for the request assets and handles caching/etag responses
* Automatically sends a 404 and exits if path doesn't exist or fails a security check
*
* @param string $contentType
* @param Process $process Process should compile asset and write to stdout. If null, path contents will be ouputed
* @param int $lastModified If null, filemtime will be used, should return a unix timestamp
*/
private function process($contentType, Process $process = null, $lastModified = null)
{
if ($lastModified === null) {
$lastModified = filemtime($this->path);
}
$etag = '"' . sha1($this->path . $lastModified) . '"';
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
if ($_SERVER['HTTP_IF_NONE_MATCH'] === $etag) {
header('HTTP/1.1 304 Not Modified');
exit;
}
}
$dateFormat = 'D, d M Y H:i:s T';
header('Cache-Control: public, max-age=31536000');
header('Expires: ' . gmdate($dateFormat, $lastModified + 31536000));
header('Last-Modified: ' . gmdate($dateFormat, $lastModified));
header('ETag: ' . $etag);
header('Content-Type: ' . $contentType . '; charset=utf-8');
$compile = function () use($process) {
if ($process === null) {
return file_get_contents($this->path);
} else {
header('X-Cached: false');
$paths = ['/bin/', '/usr/bin/', '/usr/local/bin/'];
foreach ($paths as $k => $v) {
if (!file_exists($v)) {
unset($paths[$k]);
}
}
$process->setEnv(['PATH' => trim(`echo \$PATH`) . ':' . implode(':', $paths)]);
$out = '';
$err = '';
$status = $process->run(function ($type, $line) use(&$out, &$err) {
if ($type === 'out') {
$out .= $line . "\n";
} else {
if ($type === 'err') {
$err .= $line . "\n";
}
}
});
if ($status === 0) {
return $out;
} else {
echo "/* PATH: " . $process->getEnv()['PATH'] . " */\n";
echo "/* TIME: " . date('Y-m-d H:i T') . " */\n";
echo "/* COMMAND: " . $process->getCommandLine() . " */\n";
echo $err;
exit;
}
}
};
if (isset($_GET['ignore-cache'])) {
echo $compile();
} else {
echo app('cache')->remember(str_slug($this->path) . '-' . md5($lastModified), 1440, $compile);
}
exit;
}
示例4: moveToCompletedProcesses
private function moveToCompletedProcesses(Process $process)
{
$env = $process->getEnv();
$suite = str_replace(EnvCommandCreator::ENV_TEST_ARGUMENT . '=', '', $env[3]);
$number = str_replace(EnvCommandCreator::ENV_TEST_CHANNEL . '=', '', $env[0]);
$numberOnThread = (int) str_replace(EnvCommandCreator::ENV_TEST_IS_FIRST_ON_CHANNEL . '=', '', $env[5]);
if (!$process->isSuccessful()) {
$this->errorCounter++;
$this->errorBuffer[$suite] = sprintf("[%s] %s", $number, $suite);
$this->errorBuffer[$suite] .= $process->getOutput();
$this->errorBuffer[$suite] .= $process->getErrorOutput();
}
$this->totalBuffer[] = new Report($suite, $process->isSuccessful(), $number, isset($this->errorBuffer[$suite]) ? $this->errorBuffer[$suite] : null, $numberOnThread);
}
示例5: run
/**
* Executes a process.
*
* @param Process $process The process to run
*
* @throws Exception\GitException
*
* @return mixed
*/
public function run(Process $process)
{
$env = array_merge($process->getEnv(), $this->getEnvVars());
$process->setEnv($env);
$process->run();
if (!$process->isSuccessful()) {
throw new GitException($process->getErrorOutput(), $process->getExitCode(), $process->getCommandLine());
}
return $process->getOutput();
}