getEnv() public method

Gets the environment variables.
public getEnv ( ) : array
return array The current environment variables
 /**
  * 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();
 }
 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
0
 /**
  * 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
0
 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
0
文件: Git.php 项目: szoper/PHPGit
 /**
  * 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();
 }