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


PHP Process::run方法代码示例

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


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

示例1: compile

 /**
  * @return string
  */
 public function compile()
 {
     $this->stopwatch->start('webpack.total');
     $this->stopwatch->start('webpack.prepare');
     // Recompile twig templates where its needed.
     $this->addSplitPoints();
     $this->addResolveConfig();
     // Write the webpack configuration file.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.config.js', $this->generator->getConfiguration());
     $this->profiler->set('compiler.performance.prepare', $this->stopwatch->stop('webpack.prepare')->getDuration());
     $this->stopwatch->start('webpack.compiler');
     $this->process->run();
     $output = $this->process->getOutput() . $this->process->getErrorOutput();
     $this->profiler->set('compiler.executed', true);
     $this->profiler->set('compiler.successful', strpos($output, 'Error:') === false);
     $this->profiler->set('compiler.last_output', $output);
     if ($this->profiler->get('compiler.successful')) {
         $this->tracker->rebuild();
     }
     // Finally, write some logging for later use.
     file_put_contents($this->cache_dir . DIRECTORY_SEPARATOR . 'webpack.compiler.log', $output);
     $this->profiler->set('compiler.performance.compiler', $this->stopwatch->stop('webpack.compiler')->getDuration());
     $this->profiler->set('compiler.performance.total', $this->stopwatch->stop('webpack.total')->getDuration());
     return $output;
 }
开发者ID:studionone,项目名称:webpack-bundle,代码行数:28,代码来源:Compiler.php

示例2: 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('\'' => '"', '"' => '\\"'))));
     $this->process->run();
 }
开发者ID:AntonKalachev,项目名称:ChainedStepsExtension,代码行数:14,代码来源:FeatureContext.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->downloadConfiguration();
     $library = new GLibc();
     try {
         $this->download()->extract();
         $library->setEnv($this->env)->setProjectDir($this->baseDir)->initialize()->boot($input, $output);
         $configure = $this->projectDir . '/' . $library->configure();
         $this->projectDir = dirname($this->projectDir) . '/glibc-build';
         $this->fs->mkdir($this->projectDir);
         $this->output->write('    Building   :  ');
         $process = new Process($configure, $this->projectDir, $this->env->toArray());
         $process->setTimeout(0);
         $process->run();
         if ($process->isSuccessful()) {
             $process->setCommandLine('make -j4 && make -j4 install');
             $process->run();
         }
         if ($process->isSuccessful()) {
             $message = '<info>✔</info>';
         } else {
             $message = '<error>✕</error>';
         }
         $this->output->writeln($message);
     } catch (\Exception $e) {
         $this->cleanUp();
         throw $e;
     }
     $this->createConfiguration();
     $this->output->writeln(sprintf(" <info>%s</info>  Droidphp Installer <info>successfully configured</info> Now you can:\n" . "    * Run :\n" . "        1. Execute the <comment>%s build:components</comment> command.\n" . " To Build the project\n\n", defined('PHP_WINDOWS_VERSION_BUILD') ? 'OK' : '✔', basename($_SERVER['PHP_SELF'])));
 }
开发者ID:mozanturhan,项目名称:droidphp-installer,代码行数:31,代码来源:SetupCommand.php

示例4: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $env = array('APP_INCLUDE' => $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/autoload.php', 'VVERBOSE' => 1, 'QUEUE' => $input->getArgument('queues'));
     $workerCommand = 'php ' . $this->getContainer()->getParameter('bcc_resque.resque.vendor_dir') . '/chrisboulton/php-resque/resque.php';
     if (!$input->getOption('foreground')) {
         $workerCommand = 'nohup ' . $workerCommand . ' > ' . $this->getContainer()->getParameter('kernel.logs_dir') . '/resque.log 2>&1 & echo $!';
     }
     $process = new Process($workerCommand, null, $env);
     $output->writeln(\sprintf('Starting worker <info>%s</info>', $process->getCommandLine()));
     // if foreground, we redirect output
     if ($input->getOption('foreground')) {
         $process->run(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
     } else {
         $process->run();
         $pid = \trim($process->getOutput());
         if (function_exists('gethostname')) {
             $hostname = gethostname();
         } else {
             $hostname = php_uname('n');
         }
         $output->writeln(\sprintf('<info>Worker started</info> %s:%s:%s', $hostname, $pid, $input->getArgument('queues')));
     }
 }
开发者ID:rosstuck,项目名称:BCCResqueBundle,代码行数:25,代码来源:StartWorkerCommand.php

示例5: runShellCommand

 /**
  * Executes a shell command.
  *
  * @param string $command
  *
  * @return $this
  */
 public function runShellCommand($command)
 {
     $this->process = new Process($command);
     $this->exitCode = $this->process->run();
     $this->stdOutput = $this->process->getOutput();
     $this->stdError = $this->process->getErrorOutput();
     return $this;
 }
开发者ID:cheppers,项目名称:robo-phpcs,代码行数:15,代码来源:Cli.php

示例6: iRun

 /**
  * @When I run :command
  * @When I run :command on :server
  */
 public function iRun($command, $server = 'default')
 {
     if (!isset($this->config[$server])) {
         throw new \Exception(sprintf('Configuration not found for server "%s"', $server));
     }
     $this->process = $this->createProcess($command, $this->config[$server]);
     $this->process->run();
 }
开发者ID:DrSchimke,项目名称:BehatShellExtension,代码行数:12,代码来源:ShellContext.php

示例7: run

 /**
  * Run a command as a process.
  *
  * @param string $command
  * @return self
  */
 public function run($command)
 {
     $this->command = escapeshellcmd($command);
     $this->process->setCommandLine($this->command);
     $this->process->run();
     $this->validateRun();
     return $this;
 }
开发者ID:vuthaihoc,项目名称:pdf-parser,代码行数:14,代码来源:Process.php

示例8: archive

 /**
  * Executes the backup command.
  */
 public function archive()
 {
     $this->process->setCommandLine($this->getCommand());
     $this->process->run();
     if ($this->process->getErrorOutput()) {
         throw new \RuntimeException($this->process->getErrorOutput());
     }
 }
开发者ID:nadimtuhin,项目名称:archiver,代码行数:11,代码来源:ZipArchiver.php

示例9: process

 /**
  * @param $command
  * @throws ShellProcessFailed
  * @throws \Symfony\Component\Process\Exception\LogicException
  */
 public function process($command)
 {
     if (empty($command)) {
         return;
     }
     $this->process->setCommandLine($command);
     $this->process->run();
     if (!$this->process->isSuccessful()) {
         throw new ShellProcessFailed($this->process->getErrorOutput());
     }
 }
开发者ID:parabol,项目名称:laravel-cms,代码行数:16,代码来源:ShellProcessor.php

示例10: execute

 /**
  * Runs the command, returns the proc after it's done
  *
  * @param array $options
  * @param callable  $callback
  *
  * @return Process
  */
 public function execute($options = array(), $callback = null)
 {
     $cmd = $this->buildCommand($options);
     $env = defined('PHP_WINDOWS_VERSION_BUILD') ? Habitat::getAll() : null;
     $proc = new Process($cmd, null, $env, null, $timeout = 600);
     if (!is_callable($callback)) {
         $proc->run();
     } else {
         $proc->run($callback);
     }
     return $proc;
 }
开发者ID:luispabon,项目名称:paratest,代码行数:20,代码来源:ParaTestInvoker.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $env = array('QUEUE' => $input->getArgument('queues'), 'VERBOSE' => $input->getOption('verbose'), 'COUNT' => $input->getOption('count'), 'INTERVAL' => $input->getOption('interval'), 'PREFIX' => 'resque:');
     $redisHost = $this->container->getParameter('packages.resque.host');
     $redisPort = $this->container->getParameter('packages.resque.port');
     $redisDatabase = $this->container->getParameter('packages.resque.database');
     if ($redisHost != null && $redisPort != null) {
         $backend = strpos($redisHost, 'unix:') === false ? $redisHost . ':' . $redisPort : $redisHost;
         $env['REDIS_BACKEND'] = $backend;
     }
     if (isset($redisDatabase)) {
         $env['REDIS_BACKEND_DB'] = $redisDatabase;
     }
     $opt = '';
     if (0 !== ($m = (int) $input->getOption('memory-limit'))) {
         $opt = sprintf('-d memory_limit=%dM', $m);
     }
     $workerCommand = strtr('%bin% %opt% %dir%/bin/resque', array('%bin%' => $this->getPhpBinary(), '%opt%' => $opt, '%dir%' => $this->container->getParameter('app.root_dir')));
     if (!$input->getOption('foreground')) {
         $workerCommand = strtr('nohup %cmd% > %logs_dir%/resque.log 2>&1 & echo $!', array('%cmd%' => $workerCommand, '%logs_dir%' => $this->container->getParameter('app.log_dir')));
     }
     // In windows: When you pass an environment to CMD it replaces the old environment
     // That means we create a lot of problems with respect to user accounts and missing vars
     // this is a workaround where we add the vars to the existing environment.
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         foreach ($env as $key => $value) {
             putenv($key . "=" . $value);
         }
         $env = null;
     }
     $process = new Process($workerCommand, null, $env, null, null);
     if (!$input->getOption('quiet')) {
         $output->writeln(sprintf('Executing <info>%s</info>...', $process->getCommandLine()));
     }
     if ($input->getOption('foreground')) {
         $process->run(function ($type, $buffer) use($output) {
             $output->write($buffer);
         });
     } else {
         $process->run();
         if (function_exists('gethostname')) {
             $hostname = gethostname();
         } else {
             $hostname = php_uname('n');
         }
         if (!$input->getOption('quiet')) {
             $workers = $env['COUNT'];
             $output->writeln(sprintf('Starting <info>%s %s</info> on <info>%s</info> for <info>%s</info> queues', $workers, $workers != 1 ? 'workers' : 'worker', $hostname, $input->getArgument('queues')));
         }
     }
     $output->writeln('');
 }
开发者ID:Bonscho,项目名称:packages,代码行数:52,代码来源:StartCommand.php

示例12: runTests

 /**
  * @param Process $process
  * @param OutputInterface $output
  */
 private function runTests($process, $output)
 {
     if ($output->isDebug()) {
         $process->run(function ($type, $buffer) use($output) {
             if (Process::ERR === $type) {
                 $output->write('<fg=yellow>' . $buffer . '</fg=yellow>');
             } else {
                 $output->write($buffer);
             }
         });
     } else {
         $process->run();
     }
 }
开发者ID:bitban,项目名称:php-code-quality-tools,代码行数:18,代码来源:RunCommand.php

示例13: executeCommand

 protected function executeCommand($command)
 {
     $process = new SymfonyProcess($command);
     $process->setWorkingDirectory($this->workingDirectory);
     $process->setTimeout(null);
     if ($this->isPrinted) {
         $process->run(function ($type, $buffer) {
             SymfonyProcess::ERR === $type ? print 'ER» ' . $buffer : (print $buffer);
         });
     } else {
         $process->run();
     }
     return new Result($this, $process->getExitCode(), $process->getOutput());
 }
开发者ID:sliver,项目名称:Robo,代码行数:14,代码来源:Executable.php

示例14: execute

 public function execute()
 {
     $logger = $this->getRunConfig()->getLogger();
     $this->process = new Process($this->command);
     $logger->info('Start command:' . $this->command);
     $this->process->setTimeout($this->timeout);
     $this->process->setWorkingDirectory($this->getRunConfig()->getRepositoryDirectory());
     $this->process->run();
     $output = trim($this->process->getOutput());
     $logger->info($output);
     if (!$this->process->isSuccessful()) {
         $logger->emergency($this->process->getErrorOutput());
         throw new \RuntimeException('Command not successful:' . $this->command);
     }
 }
开发者ID:funivan,项目名称:ci,代码行数:15,代码来源:ShellCommand.php

示例15: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $process = new Process('vagrant destroy --force', realpath(__DIR__ . '/../'), array_merge($_SERVER, $_ENV), null, null);
     $process->run(function ($type, $line) use($output) {
         $output->write($line);
     });
 }
开发者ID:eyp-developers,项目名称:europa,代码行数:7,代码来源:DestroyCommand.php


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