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


PHP ProcessBuilder::inheritEnvironmentVariables方法代码示例

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


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

示例1: getProcess

 protected function getProcess($drupal, $dsn)
 {
     $builder = new ProcessBuilder();
     $builder->inheritEnvironmentVariables(true);
     $builder->setWorkingDirectory($drupal);
     $builder->setPrefix('php');
     $builder->setArguments(array('-d sendmail_path=`which true`', $this->drush, 'site-install', 'standard', "--db-url={$dsn}", '-y'));
     $process = $builder->getProcess();
     return $process;
 }
开发者ID:korstiaan,项目名称:drunit,代码行数:10,代码来源:Installer.php

示例2: runCommand

 /**
  * Launches a command.
  * If '--process-isolation' parameter is specified the command will be launched as a separate process.
  * In this case you can parameter '--process-timeout' to set the process timeout
  * in seconds. Default timeout is 60 seconds.
  * If '--ignore-errors' parameter is specified any errors are ignored;
  * otherwise, an exception is raises if an error happened.
  *
  * @param string $command
  * @param array  $params
  * @return CommandExecutor
  * @throws \RuntimeException if command failed and '--ignore-errors' parameter is not specified
  */
 public function runCommand($command, $params = array())
 {
     $params = array_merge(array('command' => $command, '--no-debug' => true), $params);
     if ($this->env && $this->env !== 'dev') {
         $params['--env'] = $this->env;
     }
     $ignoreErrors = false;
     if (array_key_exists('--ignore-errors', $params)) {
         $ignoreErrors = true;
         unset($params['--ignore-errors']);
     }
     if (array_key_exists('--process-isolation', $params)) {
         unset($params['--process-isolation']);
         $phpFinder = new PhpExecutableFinder();
         $php = $phpFinder->find();
         $pb = new ProcessBuilder();
         $pb->add($php)->add($_SERVER['argv'][0]);
         if (array_key_exists('--process-timeout', $params)) {
             $pb->setTimeout($params['--process-timeout']);
             unset($params['--process-timeout']);
         }
         foreach ($params as $param => $val) {
             if ($param && '-' === $param[0]) {
                 if ($val === true) {
                     $pb->add($param);
                 } elseif (is_array($val)) {
                     foreach ($val as $value) {
                         $pb->add($param . '=' . $value);
                     }
                 } else {
                     $pb->add($param . '=' . $val);
                 }
             } else {
                 $pb->add($val);
             }
         }
         $process = $pb->inheritEnvironmentVariables(true)->getProcess();
         $output = $this->output;
         $process->run(function ($type, $data) use($output) {
             $output->write($data);
         });
         $ret = $process->getExitCode();
     } else {
         $this->application->setAutoExit(false);
         $ret = $this->application->run(new ArrayInput($params), $this->output);
     }
     if (0 !== $ret) {
         if ($ignoreErrors) {
             $this->output->writeln(sprintf('<error>The command terminated with an error code: %u.</error>', $ret));
         } else {
             throw new \RuntimeException(sprintf('The command terminated with an error status: %u.', $ret));
         }
     }
     return $this;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:68,代码来源:CommandExecutor.php

示例3: __construct

 /**
  * Constructs the proccess
  *
  * @param string $cmd command to be executed
  */
 public function __construct($cmd)
 {
     $this->builder = new ProcessBuilder();
     // Inherit environment variables from Host operating system
     $this->builder->inheritEnvironmentVariables();
     $arguments = explode(' ', $cmd);
     // Environment variables could be passed as per *nix command line (FLAG)=(VALUE) pairs
     foreach ($arguments as $key => $argument) {
         if (preg_match('/([A-Z][A-Z0-9_-]+)=(.*)/', $argument, $matches)) {
             $this->builder->setEnv($matches[1], $matches[2]);
             unset($arguments[$key]);
             // Unset it from arguments list since we do not want it in proccess (otherwise command not found is given)
         } else {
             // Break if first non-environment argument is found, since after that everything is either command or option
             break;
         }
     }
     $this->builder->setArguments($arguments);
     $this->symfonyProcess = $this->builder->getProcess();
 }
开发者ID:cooperaj,项目名称:phpci-process-plugin,代码行数:25,代码来源:Process.php

示例4: filterLoad

    public function filterLoad(AssetInterface $asset)
    {
        static $format = <<<'EOF'
var less = require('less');
var sys  = require(process.binding('natives').util ? 'util' : 'sys');

new(less.Parser)(%s).parse(%s, function(e, tree) {
    if (e) {
        less.writeError(e);
        process.exit(2);
    }

    try {
        sys.print(tree.toCSS(%s));
    } catch (e) {
        less.writeError(e);
        process.exit(3);
    }
});

EOF;
        $root = $asset->getSourceRoot();
        $path = $asset->getSourcePath();
        // parser options
        $parserOptions = array();
        if ($root && $path) {
            $parserOptions['paths'] = array(dirname($root . '/' . $path));
            $parserOptions['filename'] = basename($path);
        }
        // tree options
        $treeOptions = array();
        if (null !== $this->compress) {
            $treeOptions['compress'] = $this->compress;
        }
        $pb = new ProcessBuilder();
        $pb->inheritEnvironmentVariables();
        // node.js configuration
        if (0 < count($this->nodePaths)) {
            $pb->setEnv('NODE_PATH', implode(':', $this->nodePaths));
        }
        $pb->add($this->nodeBin)->add($input = tempnam(sys_get_temp_dir(), 'assetic_less'));
        file_put_contents($input, sprintf($format, json_encode($parserOptions), json_encode($asset->getContent()), json_encode($treeOptions)));
        $proc = $pb->getProcess();
        $code = $proc->run();
        unlink($input);
        if (0 < $code) {
            throw FilterException::fromProcess($proc)->setInput($asset->getContent());
        }
        $asset->setContent($proc->getOutput());
    }
开发者ID:laubosslink,项目名称:lab,代码行数:50,代码来源:LessFilter.php

示例5: getProcess

 /**
  * This internal method is used to create a process object.
  *
  * Made private to be sure that process creation is handled through the run method.
  * run method ensures logging and debug.
  *
  * @see self::run
  */
 private function getProcess($command, $args = array())
 {
     $base = array($this->command, '--git-dir', $this->gitDir);
     if ($this->workingDir) {
         $base = array_merge($base, array('--work-tree', $this->workingDir));
     }
     $base[] = $command;
     $builder = new ProcessBuilder(array_merge($base, $args));
     $builder->inheritEnvironmentVariables(false);
     $process = $builder->getProcess();
     $process->setEnv($this->environmentVariables);
     $process->setTimeout($this->processTimeout);
     $process->setIdleTimeout($this->processTimeout);
     return $process;
 }
开发者ID:beubi,项目名称:gitlib,代码行数:23,代码来源:Repository.php

示例6: inheritEnvironmentVariables

 /**
  * Sets whether environment variables will be inherited or not.
  *
  * @param bool $inheritEnv
  *
  * @return ProcessBuilderProxyInterface
  */
 public function inheritEnvironmentVariables(bool $inheritEnv = true) : ProcessBuilderProxyInterface
 {
     $this->processBuilder->inheritEnvironmentVariables($inheritEnv);
     return $this;
 }
开发者ID:gplanchat,项目名称:grenade,代码行数:12,代码来源:ProcessBuilderProxyTrait.php

示例7: filterLoad

 public function filterLoad(AssetInterface $asset)
 {
     $root = $asset->getSourceRoot();
     $path = $asset->getSourcePath();
     $loadPaths = $this->loadPaths;
     if ($root && $path) {
         $loadPaths[] = dirname($root . '/' . $path);
     }
     // compass does not seems to handle symlink, so we use realpath()
     $tempDir = realpath(sys_get_temp_dir());
     $compassProcessArgs = array($this->compassPath, 'compile', $tempDir);
     if (null !== $this->rubyPath) {
         array_unshift($compassProcessArgs, $this->rubyPath);
     }
     $pb = new ProcessBuilder($compassProcessArgs);
     $pb->inheritEnvironmentVariables();
     if ($this->force) {
         $pb->add('--force');
     }
     if ($this->style) {
         $pb->add('--output-style')->add($this->style);
     }
     if ($this->quiet) {
         $pb->add('--quiet');
     }
     if ($this->boring) {
         $pb->add('--boring');
     }
     if ($this->noLineComments) {
         $pb->add('--no-line-comments');
     }
     // these two options are not passed into the config file
     // because like this, compass adapts this to be xxx_dir or xxx_path
     // whether it's an absolute path or not
     if ($this->imagesDir) {
         $pb->add('--images-dir')->add($this->imagesDir);
     }
     if ($this->javascriptsDir) {
         $pb->add('--javascripts-dir')->add($this->javascriptsDir);
     }
     // options in config file
     $optionsConfig = array();
     if (!empty($loadPaths)) {
         $optionsConfig['additional_import_paths'] = $loadPaths;
     }
     if ($this->unixNewlines) {
         $optionsConfig['sass_options']['unix_newlines'] = true;
     }
     if ($this->debugInfo) {
         $optionsConfig['sass_options']['debug_info'] = true;
     }
     if ($this->cacheLocation) {
         $optionsConfig['sass_options']['cache_location'] = $this->cacheLocation;
     }
     if ($this->noCache) {
         $optionsConfig['sass_options']['no_cache'] = true;
     }
     if ($this->httpPath) {
         $optionsConfig['http_path'] = $this->httpPath;
     }
     if ($this->httpImagesPath) {
         $optionsConfig['http_images_path'] = $this->httpImagesPath;
     }
     if ($this->generatedImagesPath) {
         $optionsConfig['generated_images_path'] = $this->generatedImagesPath;
     }
     if ($this->httpJavascriptsPath) {
         $optionsConfig['http_javascripts_path'] = $this->httpJavascriptsPath;
     }
     // options in configuration file
     if (count($optionsConfig)) {
         $config = array();
         foreach ($this->plugins as $plugin) {
             $config[] = sprintf("require '%s'", addcslashes($plugin, '\\'));
         }
         foreach ($optionsConfig as $name => $value) {
             if (!is_array($value)) {
                 $config[] = sprintf('%s = "%s"', $name, addcslashes($value, '\\'));
             } elseif (!empty($value)) {
                 $config[] = sprintf('%s = %s', $name, $this->formatArrayToRuby($value));
             }
         }
         $configFile = tempnam($tempDir, 'assetic_compass');
         file_put_contents($configFile, implode("\n", $config) . "\n");
         $pb->add('--config')->add($configFile);
     }
     $pb->add('--sass-dir')->add('')->add('--css-dir')->add('');
     // compass choose the type (sass or scss from the filename)
     if (null !== $this->scss) {
         $type = $this->scss ? 'scss' : 'sass';
     } elseif ($path) {
         // FIXME: what if the extension is something else?
         $type = pathinfo($path, PATHINFO_EXTENSION);
     } else {
         $type = 'scss';
     }
     $tempName = tempnam($tempDir, 'assetic_compass');
     unlink($tempName);
     // FIXME: don't use tempnam() here
     // input
//.........这里部分代码省略.........
开发者ID:ravinderphp,项目名称:skfood,代码行数:101,代码来源:CompassFilter.php

示例8: runCommand

 /**
  * Launches a command.
  * If '--process-isolation' parameter is specified the command will be launched as a separate process.
  * In this case you can parameter '--process-timeout' to set the process timeout
  * in seconds. Default timeout is 60 seconds.
  *
  * @param string          $command
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param array           $params
  * @return InstallCommand
  */
 protected function runCommand($command, InputInterface $input, OutputInterface $output, $params = array())
 {
     $params = array_merge(array('command' => $command, '--no-debug' => true), $params);
     if ($input->hasOption('env') && $input->getOption('env') !== 'dev') {
         $params['--env'] = $input->getOption('env');
     }
     if (array_key_exists('--process-isolation', $params)) {
         unset($params['--process-isolation']);
         $phpFinder = new PhpExecutableFinder();
         $php = $phpFinder->find();
         $pb = new ProcessBuilder();
         $pb->add($php)->add($_SERVER['argv'][0]);
         if (array_key_exists('--process-timeout', $params)) {
             $pb->setTimeout($params['--process-timeout']);
             unset($params['--process-timeout']);
         }
         foreach ($params as $param => $val) {
             if ($param && '-' === $param[0]) {
                 if ($val === true) {
                     $pb->add($param);
                 } else {
                     $pb->add($param . '=' . $val);
                 }
             } else {
                 $pb->add($val);
             }
         }
         $process = $pb->inheritEnvironmentVariables(true)->getProcess();
         $process->run(function ($type, $data) use($output) {
             $output->write($data);
         });
         $ret = $process->getExitCode();
     } else {
         $this->getApplication()->setAutoExit(false);
         $ret = $this->getApplication()->run(new ArrayInput($params), $output);
     }
     if (0 !== $ret) {
         $output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
     }
     return $this;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:53,代码来源:InstallCommand.php

示例9: getProcessBuilder

 /**
  * {@inheritdoc}
  */
 public function getProcessBuilder(array $arguments, $timeout = self::DEFAULT_PROCESS_TIMEOUT)
 {
     $builder = new ProcessBuilder();
     $builder->setPrefix($this->getPhpBinary());
     $builder->setWorkingDirectory($this->getCwd());
     $builder->setArguments($arguments);
     $builder->setTimeout($timeout);
     $builder->inheritEnvironmentVariables(true);
     return $builder;
 }
开发者ID:raizeta,项目名称:WellCommerce,代码行数:13,代码来源:EnvironmentHelper.php


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