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


PHP Process::setStdin方法代码示例

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


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

示例1: 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;
 }
开发者ID:chh,项目名称:meta-template,代码行数:32,代码来源:LessTemplate.php

示例2: transform

 /**
  * {@inheritdoc)
  */
 public function transform(\Swift_Mime_Message $message)
 {
     $processor = new Process($this->getCommand());
     $processor->setStdin($message->getBody());
     $processor->run();
     if ($processor->isSuccessful()) {
         $message->addPart($processor->getOutput(), 'text/plain');
     }
 }
开发者ID:rezzza,项目名称:MailExtraBundle,代码行数:12,代码来源:Html2TextTransformer.php

示例3: testProcessPipes

 /**
  * tests results from sub processes
  *
  * @dataProvider pipesCodeProvider
  */
 public function testProcessPipes($expected, $code)
 {
     $p = new Process(sprintf('php -r \'%s\'', $code));
     $p->setStdin($expected);
     $p->run();
     $this->assertSame($expected, $p->getOutput());
     $this->assertSame($expected, $p->getErrorOutput());
     $this->assertSame(0, $p->getExitCode());
 }
开发者ID:nightchiller,项目名称:symfony,代码行数:14,代码来源:ProcessTest.php

示例4: pipe

 /**
  * Executes external command
  */
 public function pipe($value, $command)
 {
     $process = new Process($command);
     $process->setStdin($value);
     $process->run();
     if (!$process->isSuccessful()) {
         return false;
     }
     return $process->getOutput();
 }
开发者ID:buildwithcraft,项目名称:craft-utensils,代码行数:13,代码来源:Pipe.php

示例5: render

 function render($context = null, $vars = array())
 {
     $cmd = "/usr/bin/env uglifyjs";
     $process = new Process($cmd);
     $process->setStdin($this->data);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \Exception("uglifyjs exited with an error: {$process->getErrorOutput()}");
     }
     return $process->getOutput();
 }
开发者ID:chh,项目名称:pipe,代码行数:11,代码来源:UglifyJs.php

示例6: testProcessPipes

 /**
  * tests results from sub processes
  *
  * @dataProvider pipesCodeProvider
  */
 public function testProcessPipes($expected, $code)
 {
     if (strpos(PHP_OS, "WIN") === 0) {
         $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800');
     }
     $p = new Process(sprintf('php -r %s', escapeshellarg($code)));
     $p->setStdin($expected);
     $p->run();
     $this->assertSame($expected, $p->getOutput());
     $this->assertSame($expected, $p->getErrorOutput());
     $this->assertSame(0, $p->getExitCode());
 }
开发者ID:nashadalam,项目名称:symfony,代码行数:17,代码来源:ProcessTest.php

示例7: testProcessPipes

 /**
  * tests results from sub processes
  *
  * @dataProvider pipesCodeProvider
  */
 public function testProcessPipes($expected, $code)
 {
     if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) {
         $this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 fixed in http://svn.php.net/viewvc?view=revision&revision=318366');
     }
     $p = new Process(sprintf('php -r %s', escapeshellarg($code)));
     $p->setStdin($expected);
     $p->run();
     $this->assertSame($expected, $p->getOutput());
     $this->assertSame($expected, $p->getErrorOutput());
     $this->assertSame(0, $p->getExitCode());
 }
开发者ID:nervo,项目名称:symfony,代码行数:17,代码来源:ProcessTest.php

示例8: render

 function render($context = null, $vars = array())
 {
     $finder = new ExecutableFinder();
     $bin = @$this->options["coffee_bin"] ?: self::DEFAULT_COFFEE;
     $cmd = $finder->find($bin);
     if ($cmd === null) {
         throw new \UnexpectedValueException("'{$bin}' executable was not found. Make sure it's installed.");
     }
     $cmd .= " -sc";
     $process = new Process($cmd);
     $process->setEnv(array('PATH' => @$_SERVER['PATH'] ?: join(PATH_SEPARATOR, array("/bin", "/sbin", "/usr/bin", "/usr/local/bin"))));
     $process->setStdin($this->data);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException("coffee({$this->source}) returned an error:\n {$process->getErrorOutput()}");
     }
     return $process->getOutput();
 }
开发者ID:chh,项目名称:meta-template,代码行数:18,代码来源:CoffeeScriptTemplate.php

示例9: executeCommand

 public function executeCommand($command, $stdIn = null, $quiet = false)
 {
     $this->tty = $stdIn instanceof TTY;
     $command = $this->decorator->decorateCommand($command, $this);
     $this->process = $process = new Process($command, array_shift($this->workingDirectoriesStack));
     $process->setTimeout(null);
     if (null !== $stdIn) {
         if ($this->tty) {
             $process->setTty(true);
         } else {
             $process->setStdin($stdIn);
         }
     }
     $output = $this->getOutput();
     if ($output && $output->getVerbosity() >= $output::VERBOSITY_VERBOSE) {
         $output->writeln(sprintf('$ %s', $command));
         $start = true;
         $prefix = ' ---> ';
         $process->start(function ($type, $buffer) use($output, &$start, $prefix, $quiet) {
             if ($start) {
                 $buffer = $prefix . $buffer;
                 $start = false;
             }
             if ($buffer[strlen($buffer) - 1] == "\n") {
                 $start = true;
                 $buffer = strtr(substr($buffer, 0, -1), ["\n" => "\n" . $prefix]) . "\n";
             } else {
                 $buffer = strtr($buffer, ["\n" => "\n" . $prefix]);
             }
             $quiet || $output->write($buffer);
         });
         $process->wait();
     } else {
         $process->run();
     }
     if ($process->getExitCode() != 0) {
         throw new ProcessFailedException($process);
     }
     return $process->getOutput();
 }
开发者ID:mlebkowski,项目名称:crane,代码行数:40,代码来源:CommandExecutor.php

示例10: setInput

 public function setInput(Process $proc)
 {
     $proc->setStdin($this->resource);
 }
开发者ID:loicmonney,项目名称:apache-fop,代码行数:4,代码来源:StringInput.php


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