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


PHP Process::setTty方法代码示例

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


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

示例1: exec

 /**
  * Executes the command $cmd
  *
  * @param string $cmd
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param bool $silent
  * @param bool $tty
  * @return string|void
  */
 public function exec($cmd, $output = null, $silent = FALSE, $tty = FALSE)
 {
     $process = new Process($cmd);
     if ($tty) {
         $process->setTty(TRUE);
     }
     $process->setTimeout(null);
     if (!$silent && $output) {
         $output->writeln($this->messageService->lightGray('-------------------------------------------------'));
         $output->writeln($this->messageService->lightGray('Executing: ' . $cmd));
         $messageService = $this->messageService;
         $process->setTimeout(3600);
         $process->start();
         $process->wait(function ($type, $buffer) use($output, $messageService) {
             if (Process::ERR === $type) {
                 $output->writeln($messageService->red('----> ERROR START'));
                 $output->write($messageService->red('----> ' . $buffer));
                 $output->writeln($messageService->red('----> ERROR END'));
             } else {
                 $output->write($messageService->green($buffer));
             }
         });
     } else {
         $process->run();
     }
     return $process->getOutput();
 }
开发者ID:kryslin,项目名称:instance-manager,代码行数:36,代码来源:CommandService.php

示例2: addServerToHostsFile

 /**
  * Adds a virtual host name to the hosts file of the host system.
  *
  * @param VirtualHost[] $vhosts
  */
 public function addServerToHostsFile(array $vhosts)
 {
     // Get the docker-machine VM ip address.
     $dockerMachineIpAddress = Application::getDocker()->getDockerMachineIpAddress('default');
     $vhostServerNames = [];
     foreach ($vhosts as $vhost) {
         $vhostServerNames[] = $vhost->getServerName();
     }
     $vhostServerNames = join(' ', $vhostServerNames);
     $found = false;
     $hosts = file('/etc/hosts');
     if ($hosts) {
         foreach ($hosts as $line) {
             $line = str_replace(array("\t", '#'), ' ', $line);
             preg_match_all('#^(.*?) (.*)$#', $line, $matches);
             if (!empty($matches[1][0]) && !empty($matches[2][0])) {
                 $ip = trim($matches[1][0]);
                 $host = trim($matches[2][0]);
                 if ($ip == $dockerMachineIpAddress && $host == $vhostServerNames) {
                     $found = true;
                     break;
                 }
             }
         }
         if (!$found) {
             $process = new Process(sprintf('sudo sh -c "echo \'%s %s\' >> /etc/hosts"', $dockerMachineIpAddress, $vhostServerNames . ' '));
             $process->setTty(true);
             $process->run();
             print $process->getOutput();
         }
     }
 }
开发者ID:comm-press,项目名称:environment-manager,代码行数:37,代码来源:Filesystem.php

示例3: install

 /**
  * Run the installation helper.
  *
  * @return void
  */
 public function install()
 {
     if (!$this->command->output->confirm('Would you like to install the Boilerplate dependencies?', true)) {
         return;
     }
     $composer = $this->findComposer();
     $this->command->output->writeln('<info>Running Composer...</info>');
     $commands = [$composer . ' install --no-scripts', $composer . ' run-script post-root-package-install', $composer . ' run-script post-install-cmd', $composer . ' run-script post-create-project-cmd'];
     if ($this->command->input->getOption('no-ansi')) {
         $commands = array_map(function ($value) {
             return $value . ' --no-ansi';
         }, $commands);
     }
     $process = new Process(implode(' && ', $commands), $this->command->path, null, null, null);
     if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
         $process->setTty(true);
     }
     $process->run(function ($type, $line) {
         $this->command->output->write($line);
     });
     if (!$process->isSuccessful()) {
         throw new ProcessFailedException($process);
     }
     $this->command->dependencies_installed = true;
     $this->command->output->writeln('<info>Dependencies Installed!</info>');
 }
开发者ID:rappasoft,项目名称:laravel-boilerplate-installer,代码行数:31,代码来源:ComposerInstall.php

示例4: execute

 /**
  * Execute the command.
  *
  * @param  InputInterface  $input
  * @param  OutputInterface  $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!class_exists('ZipArchive')) {
         throw new RuntimeException('The Zip PHP extension is not installed. Please install it and try again.');
     }
     $this->verifyApplicationDoesntExist($directory = $input->getArgument('name') ? getcwd() . '/' . $input->getArgument('name') : getcwd());
     $output->writeln('<info>Crafting application...</info>');
     $version = $this->getVersion($input);
     $this->download($zipFile = $this->makeFilename(), $version)->extract($zipFile, $directory)->cleanUp($zipFile);
     $composer = $this->findComposer();
     $commands = [$composer . ' install --no-scripts', $composer . ' run-script post-root-package-install', $composer . ' run-script post-install-cmd', $composer . ' run-script post-create-project-cmd'];
     if ($input->getOption('no-ansi')) {
         $commands = array_map(function ($value) {
             return $value . ' --no-ansi';
         }, $commands);
     }
     $process = new Process(implode(' && ', $commands), $directory, null, null, null);
     if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
         $process->setTty(true);
     }
     $process->run(function ($type, $line) use($output) {
         $output->write($line);
     });
     $output->writeln('<comment>Application ready! Build something amazing.</comment>');
 }
开发者ID:laravel,项目名称:installer,代码行数:32,代码来源:NewCommand.php

示例5: shell

 protected function shell($command, $workingDirectory = '.', $asTty = false)
 {
     $process = new Process($command, $workingDirectory, null, null, null);
     $process->setTty($asTty);
     return $process->run(function ($type, $buffer) {
         echo $buffer;
     }) == 0;
 }
开发者ID:linusshops,项目名称:prophet,代码行数:8,代码来源:Command.php

示例6: install

 /**
  * Run the installation helper.
  *
  * @return void
  */
 public function install()
 {
     $process = new Process($this->command(), $this->command->path);
     if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
         $process->setTty(true);
     }
     $process->run(function ($type, $line) {
         $this->command->output->write($line);
     });
 }
开发者ID:laravel,项目名称:spark-installer,代码行数:15,代码来源:RunSparkInstall.php

示例7: add

 /**
  * @param string      $cmd
  * @param string|null $workingDirectory
  * @param bool        $isDryRun
  * @param bool        $tty
  * @return $this
  */
 public function add($cmd, $workingDirectory, $isDryRun = false, $tty = false)
 {
     $process = null;
     if (!$isDryRun) {
         $process = new Process($cmd);
         $process->setTty($tty);
         $process->setWorkingDirectory($workingDirectory);
         $this->parallelProcessRunner->add($process);
     }
     return $this;
 }
开发者ID:octava,项目名称:geggs,代码行数:18,代码来源:ParallelProcess.php

示例8: composerUpdate

 private function composerUpdate()
 {
     $process = new Process('composer update "flashtag/*"');
     $process->setTty(true);
     $process->run(function ($type, $buffer) {
         if ('err' === $type) {
             echo $buffer;
         } else {
             echo $buffer;
         }
     });
 }
开发者ID:flashtag,项目名称:core,代码行数:12,代码来源:Update.php

示例9: getProcess

 /**
  * Run the given script on the given host.
  *
  * @param  string  $host
  * @param  \Laravel\Envoy\Task  $task
  * @return int
  */
 protected function getProcess($host, Task $task)
 {
     $target = $this->getConfiguredServer($host) ?: $host;
     if (in_array($target, ['local', 'localhost', '127.0.0.1'])) {
         $process = new Process($task->script);
         $process->setTty(true);
     } else {
         $delimiter = 'EOF-LARAVEL-ENVOY';
         $process = new Process("ssh {$target} 'bash -se' << \\{$delimiter}" . PHP_EOL . 'set -e' . PHP_EOL . $task->script . PHP_EOL . $delimiter);
     }
     return [$target, $process->setTimeout(null)];
 }
开发者ID:QuanticPotato,项目名称:envoy,代码行数:19,代码来源:RemoteProcessor.php

示例10: install

 /**
  * @param string $theme
  */
 private function install($theme)
 {
     $this->info(sprintf("Installing theme %s", $theme));
     $process = new Process(sprintf('composer require "%s"', $theme));
     $process->setTty(true);
     $process->run(function ($type, $buffer) {
         if ('err' === $type) {
             echo $buffer;
         } else {
             echo $buffer;
         }
     });
 }
开发者ID:flashtag,项目名称:front,代码行数:16,代码来源:InstallTheme.php

示例11: runCommand

 /**
  * @param string $cmd
  * @param bool   $isDryRun
  * @param bool   $tty
  * @return null|Process
  */
 public function runCommand($cmd, $isDryRun = false, $tty = false)
 {
     $this->getLogger()->debug($cmd, ['dry_run' => $isDryRun, 'tty' => $tty]);
     $process = null;
     if (!$isDryRun) {
         $process = new Process($cmd);
         $process->setTty($tty);
         $process->mustRun();
         $process->setTimeout(null);
         $process->setIdleTimeout(null);
         $process->setWorkingDirectory($this->getRepositoryPath());
     }
     return $process;
 }
开发者ID:octava,项目名称:geggs,代码行数:20,代码来源:AbstractProvider.php

示例12: process

 /**
  * @param $command
  * @param $option
  */
 public function process($command, array $option = null)
 {
     if (true === is_array($command)) {
         $command = implode(' ', $command);
     }
     if (true === isset($option['timeout'])) {
         $timeout = $option['timeout'];
     } else {
         $timeout = null;
     }
     if (true === isset($option['tty'])) {
         $tty = $option['tty'];
     } else {
         $tty = false;
     }
     if ($this->verbose) {
         $print = true;
         $this->message('IN >> ' . $command);
     } else {
         if (true === isset($option['print'])) {
             $print = $option['print'];
         } else {
             $print = true;
             $this->message($command);
         }
     }
     $process = new Process($command);
     $process->setTty($tty);
     $process->setTimeout($timeout);
     $process->run(function ($type, $buf) use($print) {
         if (true == $print) {
             $buffers = explode(PHP_EOL, trim($buf, PHP_EOL));
             foreach ($buffers as $buffer) {
                 if (Process::ERR === $type) {
                     echo 'ERR > ' . $buffer . PHP_EOL;
                 } else {
                     if ('reach it successfully.' == $buffer) {
                         print_r($command);
                     }
                     echo \Peanut\Console\Color::text('OUT > ', 'black') . $buffer . PHP_EOL;
                 }
             }
         }
     });
     if (!$process->isSuccessful() && $process->getErrorOutput()) {
         throw new \Peanut\Console\Exception(trim($process->getErrorOutput()));
     }
     return new \Peanut\Console\Result($process->getErrorOutput() . $process->getOutput());
 }
开发者ID:yejune,项目名称:bootapp,代码行数:53,代码来源:Command.php

示例13: execute

 /**
  * Execute the command.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->verifyApplicationDoesntExist($directory = $input->getArgument('name') ? getcwd() . '/' . $input->getArgument('name') : getcwd(), $output);
     $output->writeln('<info>Crafting Lucid application...</info>');
     /*
      * @TODO: Get Lucid based on the Laravel version.
      */
     $process = new Process($this->findComposer() . ' create-project laravel/laravel ' . $directory);
     if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
         $process->setTty(true);
     }
     $process->run(function ($type, $line) use($output) {
         $output->write($line);
     });
     $output->writeln('<comment>Application ready! Make your dream a reality.</comment>');
 }
开发者ID:vinelab,项目名称:lucid-console,代码行数:22,代码来源:NewCommand.php

示例14: execute

 /**
  * Execute the command.
  *
  * @param  InputInterface  $input
  * @param  OutputInterface  $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (!class_exists('ZipArchive')) {
         throw new RuntimeException('The Zip PHP extension is not installed. Please install it and try again.');
     }
     $this->verifyApplicationDoesntExist($directory = getcwd() . '/' . $input->getArgument('name'), $output);
     $output->writeln('<info>Crafting application...</info>');
     $version = $this->getVersion($input);
     $this->download($zipFile = $this->makeFilename(), $version)->extract($zipFile, $directory)->cleanUp($zipFile);
     $composer = $this->findComposer();
     $commands = [$composer . ' install --no-scripts'];
     $process = new Process(implode(' && ', $commands), $directory, null, null, null);
     $process->setTty(true);
     $process->run(function ($type, $line) use($output) {
         $output->write($line);
     });
     $output->writeln('<comment>Application ready! Build something amazing.</comment>');
 }
开发者ID:xueron,项目名称:pails-installer,代码行数:25,代码来源:NewCommand.php

示例15: 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


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