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


PHP Process::getEnv方法代码示例

本文整理汇总了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();
 }
开发者ID:SimonPotthast,项目名称:jenkins-test,代码行数:22,代码来源:FeatureContext.php

示例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()]);
     }
 }
开发者ID:shnhrrsn,项目名称:laravel-assets,代码行数:20,代码来源:ProcessCompiler.php

示例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;
 }
开发者ID:saverio,项目名称:laravel-assets,代码行数:67,代码来源:Controller.php

示例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);
 }
开发者ID:jarednova,项目名称:fastest,代码行数:14,代码来源:Processes.php

示例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();
 }
开发者ID:szoper,项目名称:PHPGit,代码行数:19,代码来源:Git.php


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