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


PHP Process::setInput方法代码示例

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


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

示例1: kanjiToRomaji

 public static function kanjiToRomaji($input, &$returnCode = '')
 {
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         return $input;
     }
     $japanese = "/([\\x{3000}-\\x{303f}\\x{3040}-\\x{309f}\\x{30a0}-\\x{30ff}\\x{ff00}-\\x{ff9f}\\x{4e00}-\\x{9faf}\\x{3400}-\\x{4dbf}])+/iu";
     preg_match_all($japanese, $input, $matches);
     if (empty($matches[0]) || !is_array($matches[0])) {
         return $input;
     }
     $placeholders = ['in' => $matches[0], 'out' => []];
     $uniq = uniqid();
     $kakasi = 'kakasi -i euc -w | kakasi -i euc -Ha -Ka -Ja -Ea -ka';
     $process = new Process($kakasi);
     $words = implode($uniq, $placeholders['in']);
     $convertedWords = mb_convert_encoding($words, 'eucjp', 'utf-8');
     $process->setInput($convertedWords);
     $process->run();
     if (!$process->isSuccessful()) {
         return IRCHelper::colorText('ERROR', IRCHelper::COLOR_RED) . ': can\'t run kakasi';
     }
     $romaji = $process->getOutput();
     $placeholders['out'] = explode($uniq, $romaji);
     $input = str_replace($placeholders['in'], $placeholders['out'], $input);
     return $input;
 }
开发者ID:xandros15,项目名称:Saya-Bot,代码行数:26,代码来源:Filter.php

示例2: execute

 /**
  * @return SystemData Process output.
  */
 public function execute()
 {
     $process = new Process($this->command);
     isset($this->input) && $process->setInput($this->input);
     $process->run();
     return new SystemData($process->getOutput(), $process->getErrorOutput(), $process->getExitCode());
 }
开发者ID:scriptfusion,项目名称:open-dash-kernel,代码行数:10,代码来源:SystemDataProvider.php

示例3: iRunPhpspecAndAnswerWhenAskedIfIWantToGenerateTheCode

 /**
  * @When I run phpspec and answer :answer when asked if I want to generate the code
  */
 public function iRunPhpspecAndAnswerWhenAskedIfIWantToGenerateTheCode($answer)
 {
     $command = sprintf('%s %s', $this->buildPhpSpecCmd(), 'run');
     $env = array('SHELL_INTERACTIVE' => true, 'HOME' => $_SERVER['HOME']);
     $this->process = $process = new Process($command);
     $process->setEnv($env);
     $process->setInput($answer);
     $process->run();
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:12,代码来源:IsolatedProcessContext.php

示例4: check

 /**
  * Performs an obscure check with the given password
  *
  * @param string $password
  * @throws ProcessFailedException
  */
 public function check($password)
 {
     if (empty($password)) {
         throw new InvalidArgumentException('The password cannot be empty');
     }
     $process = new Process($this->command);
     $process->setInput($password);
     $process->mustRun();
     return $this->verifyOutput($process->getOutput());
 }
开发者ID:gisostallenberg,项目名称:correct-horse-battery-staple,代码行数:16,代码来源:CorrectHorseBatteryStaple.php

示例5: renderNotebook

 protected function renderNotebook($content)
 {
     $retval = null;
     $process = new Process(__DIR__ . "/convertor.py");
     $process->setInput($content);
     $process->run();
     if ($process->isSuccessful()) {
         return $process->getOutput();
     } else {
         return "Parsing error";
     }
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-NotebookViewer,代码行数:12,代码来源:NotebookContent.php

示例6: doRender

 protected function doRender()
 {
     $renderer = new DotGraphRenderer();
     $dot_graph = $renderer->renderGraph($this->state_machine);
     $process = new Process('dot -Tsvg');
     $process->setInput($dot_graph);
     $process->run();
     if (!$process->isSuccessful()) {
         throw new RuntimeError($process->getErrorOutput());
     }
     return $process->getOutput();
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-vendor,代码行数:12,代码来源:ConsoleStateMachineRenderer.php

示例7: exists

 /**
  * @Given :class exists
  */
 public function exists($class)
 {
     $descCmd = $this->buildCmd(sprintf('desc %s', $class));
     $runCmd = $this->buildCmd('run');
     $cmd = sprintf('%s && %s', $descCmd, $runCmd);
     $process = new Process($cmd);
     $process->setEnv(['SHELL_INTERACTIVE' => true]);
     $process->setInput('Y');
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
 }
开发者ID:mike182uk,项目名称:phpspec-rename,代码行数:16,代码来源:FeatureContext.php

示例8: iRunTheSpecFor

 /**
  * @When I run the spec for :fqcn
  */
 public function iRunTheSpecFor($fqcn)
 {
     $cmd = $this->buildCmd(sprintf('run %s', $fqcn));
     $cmd .= ' --format pretty';
     $process = new Process($cmd);
     $process->setEnv(['SHELL_INTERACTIVE' => true]);
     $process->setInput('Y');
     $process->run();
     $this->lastOutput = $process->getOutput();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException($process->getErrorOutput());
     }
 }
开发者ID:mike182uk,项目名称:phpspec-run-fqcn,代码行数:16,代码来源:FeatureContext.php

示例9: processUrl

 public function processUrl($url)
 {
     $result = $this->fetchUrl($url);
     $fileContent = $result->getBody()->getContents();
     $process = new Process('gpg --batch -sab');
     $process->setInput($fileContent);
     $process->run();
     $error = $process->getErrorOutput();
     $signatureStruct = new SignatureStruct();
     $signatureStruct->setDownloadUrl($url);
     $signatureStruct->setSignature($process->getOutput());
     $signatureStruct->setSignatureType('gpg');
     $signatureStruct->setSha256(hash('sha256', $fileContent));
     //file_put_contents('test_archive.zip', $fileContent);
     //file_put_contents('test_archive.zip.asc', $process->getOutput());
     return $signatureStruct;
 }
开发者ID:Cotya,项目名称:SignatureChainer,代码行数:17,代码来源:Client.php

示例10: letsencrypt

 /**
  * @param string $script
  * @param string $domain
  * @param string $recoveryMail
  * @param string $logsDir
  */
 private function letsencrypt($script, $domain, $recoveryMail, $logsDir)
 {
     try {
         $command = [];
         // Script
         $command[] = $script;
         // We will use Symfony for the well-known challenge
         $command[] = 'certonly';
         $command[] = '--manual';
         // Disable interaction
         $command[] = '--manual-public-ip-logging-ok';
         $command[] = '--agree-tos';
         $command[] = '--renew-by-default';
         // Recovery e-mail
         $command[] = '--email';
         $command[] = $recoveryMail;
         // Logs directory
         $command[] = '--logs-dir';
         $command[] = $logsDir;
         // Domain
         $command[] = '--domain';
         $command[] = $domain;
         $process = new Process(implode(' ', $command));
         $stdin = fopen('php://temp', 'w+');
         $process->setInput($stdin);
         $process->start(function ($type, $data) {
             if (strpos($data, '.well-known/acme-challenge') !== false) {
                 preg_match('~\\.well-known/acme-challenge/([^ ]+) ~U', $data, $match);
                 var_dump($match);
             }
         });
         $gotCert = false;
         while ($process->isRunning()) {
             /*if (! $gotCert && strpos($process->getOutput(), 'Press ENTER to continue') !== false) {
                   $gotCert = true;
                   // ...
                   fwrite($stdin, "\n");
               }*/
         }
     } catch (\Exception $e) {
         $this->handleError($e->getMessage(), $domain);
     }
 }
开发者ID:tgalopin,项目名称:LetsEncryptBundle,代码行数:49,代码来源:TgaLetsencryptCommand.php

示例11: executeCommandStdin

 protected function executeCommandStdin($command, $input = null)
 {
     $process = new Process($command);
     $process->setTimeout(null);
     if ($input) {
         $process->setInput($input);
     }
     if ($this->workingDirectory) {
         $process->setWorkingDirectory($this->workingDirectory);
     }
     $this->startTimer();
     if ($this->isPrinted) {
         $process->run(function ($type, $buffer) {
             echo $buffer;
         });
     } else {
         $process->run();
     }
     $this->stopTimer();
     return new Result($this, $process->getExitCode(), $process->getOutput(), ['time' => $this->getExecutionTime()]);
 }
开发者ID:bangpound,项目名称:robo-assets,代码行数:21,代码来源:Sassc.php

示例12: save

 /**
  * Saves the current user's crontab.
  * 
  * @return Crontab
  * @throws \RuntimeException
  */
 public function save()
 {
     $process = new Process('crontab');
     $process->setInput($this->_rawTable);
     $process->run();
     if (!$process->isSuccessful()) {
         $errorOutput = $process->getErrorOutput();
         if ($errorOutput) {
             throw new \RuntimeException(sprintf('There has been an error saving the crontab. Here\'s the output from the shell: %s', trim($errorOutput)));
         }
         throw new \RuntimeException('There has been an error saving the crontab.');
     }
     return $this;
 }
开发者ID:Kingbalou,项目名称:cronkeep,代码行数:20,代码来源:Crontab.php

示例13: testIteratorInput

 public function testIteratorInput()
 {
     $nextData = 'ping';
     $input = function () use(&$nextData) {
         while (false !== $nextData) {
             (yield $nextData);
             (yield $nextData = '');
         }
     };
     $input = $input();
     $process = new Process(self::$phpBin . ' -r ' . escapeshellarg('stream_copy_to_stream(STDIN, STDOUT);'));
     $process->setInput($input);
     $process->start(function ($type, $data) use($input, &$nextData) {
         if ('ping' === $data) {
             $h = fopen('php://memory', 'r+');
             fwrite($h, 'pong');
             rewind($h);
             $nextData = $h;
             $input->next();
         } else {
             $nextData = false;
         }
     });
     $process->wait();
     $this->assertSame('pingpong', $process->getOutput());
 }
开发者ID:hason,项目名称:symfony,代码行数:26,代码来源:ProcessTest.php

示例14: testNonBlockingNorClearingIteratorOutput

 public function testNonBlockingNorClearingIteratorOutput()
 {
     $input = new InputStream();
     $process = new Process(self::$phpBin . ' -r ' . escapeshellarg('fwrite(STDOUT, fread(STDIN, 3));'));
     $process->setInput($input);
     $process->start();
     $output = array();
     foreach ($process->getIterator(false, false) as $type => $data) {
         $output[] = array($type, $data);
         break;
     }
     $expectedOutput = array(array($process::OUT, ''));
     $this->assertSame($expectedOutput, $output);
     $input->write(123);
     foreach ($process->getIterator(false, false) as $type => $data) {
         if ('' !== $data) {
             $output[] = array($type, $data);
         }
     }
     $this->assertSame('123', $process->getOutput());
     $this->assertFalse($process->isRunning());
     $expectedOutput = array(array($process::OUT, ''), array($process::OUT, '123'));
     $this->assertSame($expectedOutput, $output);
 }
开发者ID:alekitto,项目名称:symfony,代码行数:24,代码来源:ProcessTest.php

示例15: command

 /**
  * @param string $command
  * @param string|string[] $filter
  * @param array $options
  * @param string $input
  * @return string
  * @throws CommandException
  */
 public function command($command, $filter = null, array $options = array(), $input = null)
 {
     $parts = [$this->bin];
     foreach ($this->rcOptions as $option) {
         $parts[] = $option;
     }
     $filter = array_filter((array) $filter, 'trim');
     if ($filter) {
         foreach ($filter as $f) {
             $parts[] = "( " . $f . " )";
         }
     }
     $parts[] = $command;
     foreach ($options as $param) {
         $parts[] = $param;
     }
     $process = new Process($this->createCommandLine($parts));
     if ($input) {
         $process->setInput($input);
     }
     $process->run();
     if (!$process->isSuccessful()) {
         throw new CommandException($process);
     }
     return $process->getOutput();
 }
开发者ID:davidbadura,项目名称:taskwarrior,代码行数:34,代码来源:Taskwarrior.php


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