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


PHP Process::start方法代码示例

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


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

示例1: iRunBehat

 /**
  * @When /^I run behat$/
  */
 public function iRunBehat()
 {
     $this->process->setWorkingDirectory($this->workingDir);
     $this->process->setCommandLine(sprintf('%s %s %s %s', $this->phpBin, escapeshellarg(BEHAT_BIN_PATH), strtr('--format-settings=\'{"timer": false}\'', array('\'' => '"', '"' => '\\"')), '--format=progress'));
     $this->process->start();
     $this->process->wait();
 }
开发者ID:icambridge,项目名称:BehatPageObjectExtension,代码行数:10,代码来源:BehatRunnerContext.php

示例2: setUpPhpServer

 private static function setUpPhpServer()
 {
     self::$process = new Process('php -S [::1]:8999', __DIR__ . '/../../Resources/Scripts');
     self::$process->setTimeout(1);
     self::$process->start();
     usleep(100000);
 }
开发者ID:xsolla,项目名称:xsolla-sdk-php,代码行数:7,代码来源:ServerTest.php

示例3: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $testDir = dirname(dirname(__DIR__));
     $cmd = "php -S 127.0.0.1:8000 -t {$testDir}/server/web {$testDir}/server/web/index.php";
     self::$serverProcess = new Process($cmd);
     self::$serverProcess->start();
 }
开发者ID:rstgroup,项目名称:oauth2-client,代码行数:7,代码来源:ClientTest.php

示例4: startDemoServer

 /**
  * Starts the internal PHP server using excerpts from my (awesome)
  * travel blog as the docroot.
  */
 public function startDemoServer()
 {
     $docRoot = realpath(__DIR__ . '/../../demo/mike-on-a-bike.com');
     $this->demoServerProcess = new Process('php -S ' . self::HOST . ' -t ' . $docRoot);
     $this->demoServerProcess->setTimeout(3600);
     $this->demoServerProcess->start();
 }
开发者ID:mihaeu,项目名称:tarantula,代码行数:11,代码来源:DemoServer.php

示例5: start

 /**
  * @throws \RuntimeException if server could not be started within $this->timeout seconds
  */
 public function start()
 {
     if ($this->isRunning()) {
         return;
     }
     $processBuilder = new ProcessBuilder(['/usr/bin/php', '-S', "{$this->host}:{$this->port}", '-t', $this->webRoot]);
     $processBuilder->setTimeout(10);
     $this->serverProcess = $processBuilder->getProcess();
     $this->serverProcess->start();
     // server needs some time to boot up
     $serverIsBooting = true;
     $timeoutAt = time() + $this->timeout;
     while ($this->serverProcess->isRunning() && $serverIsBooting) {
         try {
             $socket = fsockopen($this->host, $this->port);
             if ($socket) {
                 $serverIsBooting = false;
             }
         } catch (\Exception $ex) {
             // server not ready
             if ($timeoutAt < time()) {
                 throw new \RuntimeException("Could not start Web Server [host = {$this->host}; port = {$this->port}; web root = {$this->webRoot}]");
             }
         }
         usleep(10);
     }
 }
开发者ID:paq85,项目名称:WebServer,代码行数:30,代码来源:PhpBuiltInWebServer.php

示例6: 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}\' --no-colors', array('\'' => '"', '"' => '\\"'))));
     $this->process->start();
     $this->process->wait();
 }
开发者ID:cam5,项目名称:WebApiExtension,代码行数:15,代码来源:FeatureContext.php

示例7: __construct

 /**
  * Private constructor for an local web server instance
  * @param $serverOptions
  * @param $workingDir
  */
 private function __construct($serverOptions, $workingDir)
 {
     echo "Creating local server with {$serverOptions} and working dir {$workingDir}\n";
     $this->waitForServerToStop();
     $this->process = new Process("php -S 127.0.0.1:6789 {$serverOptions}", $workingDir);
     $this->process->start();
     $this->waitForServerStart();
 }
开发者ID:bamarni,项目名称:gastonjs,代码行数:13,代码来源:LocalWebServer.php

示例8: startServer

 protected static function startServer()
 {
     if (!static::$enabled) {
         return;
     }
     self::$server = new Process(static::$command . ' &>/dev/null', __DIR__ . '/Fixtures');
     self::$server->start();
     static::pollWait();
 }
开发者ID:Banjerr,项目名称:infusionWholesaler,代码行数:9,代码来源:AbstractIntegrationTest.php

示例9: run

 /**
  * Run the process.
  */
 public function run()
 {
     $this->process->start(function ($type, $buffer) {
         if (Process::ERR === $type) {
             $this->pipe->error($buffer);
         } else {
             $this->pipe->output($buffer);
         }
     });
     $this->waitStrategy->wait($this->process);
 }
开发者ID:Elfiggo,项目名称:dock-cli,代码行数:14,代码来源:InteractiveProcess.php

示例10: start

 /**
  * {@inheritdoc}
  */
 public function start()
 {
     if (isset($this->deferred)) {
         throw new \RuntimeException('Tasks is already started');
     }
     $this->deferred = new Deferred();
     $this->process->start(function () {
         $this->outputBuffer->enqueue(func_get_args());
     });
     return $this->deferred->promise();
 }
开发者ID:jderusse,项目名称:async,代码行数:14,代码来源:SymfonyProcess.php

示例11: startServer

 public function startServer()
 {
     $finder = new PhpExecutableFinder();
     if (false === ($binary = $finder->find())) {
         throw new \RuntimeException('Unable to find PHP binary to run server.');
     }
     $builder = new ProcessBuilder(['exec', $binary, '-S', $this->address, realpath(__DIR__ . '/../Resource/server.php')]);
     $builder->setWorkingDirectory(realpath(__DIR__ . '/../Resource'));
     $builder->setTimeout(null);
     $this->process = $builder->getProcess();
     $this->process->start();
     $this->waitServer();
 }
开发者ID:jderusse,项目名称:composer-warmup,代码行数:13,代码来源:PhpServerCompiler.php

示例12: beforeSuite

 public function beforeSuite()
 {
     $router = '' != $this->router ? escapeshellarg($this->router) : '';
     // See https://github.com/symfony/symfony/issues/5030 for why exec
     // is used here
     $this->process = new Process(sprintf('exec php -S %s -t %s %s', escapeshellarg($this->host), escapeshellarg($this->docroot), $router));
     $this->process->start();
     sleep(1);
     if (!$this->process->isRunning()) {
         throw new \RuntimeException('PHP built-in server process terminated immediately');
     }
     // Also trap fatal errors to make sure running processes are terminated
     register_shutdown_function([$this, 'afterSuite']);
 }
开发者ID:adamquaile,项目名称:behat-php-server-extension,代码行数:14,代码来源:RunPhpServerListener.php

示例13: _reconfigure

 /**
  * {@inheritDoc}
  *
  * Starts the connection
  */
 public function _reconfigure($config = array())
 {
     parent::_reconfigure($config);
     if (!isset($this->config['username'])) {
         throw new \Exception("Sauce Connect Extension requires a username.");
     }
     if (!isset($this->config['accesskey'])) {
         throw new \Exception("Sauce Connect Extension requires a accesskey.");
     }
     $connect = __DIR__ . '/../../../bin/sauce_connect';
     if (!file_exists($connect)) {
         $connect = __DIR__ . '/../../../../bin/sauce_connect';
     }
     if (!file_exists($connect)) {
         throw new \Exception("Couldnt find the bin directory... Make sure its in ./bin or ./vendor/bin/");
     }
     $processBuilder = new ProcessBuilder([$connect]);
     $processBuilder->addEnvironmentVariables(['SAUCE_USERNAME' => $this->config['username'], 'SAUCE_ACCESS_KEY' => $this->config['accesskey']]);
     $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 60;
     $this->process = $processBuilder->getProcess();
     $this->process->setTimeout(0);
     $this->process->start(function ($type, $buffer) {
         $buffer = explode("\n", $buffer);
         foreach ($buffer as $line) {
             if (strpos($line, 'Press any key to see more output') === false) {
                 file_put_contents(codecept_output_dir() . 'sauce_connect.log', $line . "\n", FILE_APPEND);
             }
         }
     });
     $timer = 0;
     $connected = false;
     $this->writeln(["", "----------------------------------------------------------------------------", "Attempting to connect to SauceLabs. Waiting {$timeout} seconds."]);
     while ($this->process->isRunning() && $timer < $timeout) {
         $output = $this->process->getOutput();
         if (strpos($output, 'Connected! You may start your tests.') !== false) {
             $connected = true;
             break;
         }
         sleep(1);
         $timer++;
         if ($timer % 5 === 0) {
             $this->write('.');
         }
     }
     if (false === $connected) {
         $this->process->stop();
         throw new \Exception(sprintf("Could not start tunnel. Check %ssauce_connect.log for more information.", codecept_output_dir()));
     }
     $this->writeln(["", "Connected to SauceLabs", "----------------------------------------------------------------------------", ""]);
 }
开发者ID:lfgamers,项目名称:sauce-connect-extension,代码行数:55,代码来源:SauceConnectExtension.php

示例14: startCapture

 /**
  * @BeforeScenario
  * @param ScenarioEvent $event
  */
 public function startCapture(ScenarioEvent $event)
 {
     if ($this->tagFilter !== NULL && !in_array($this->tagFilter, $event->getScenario()->getTags(), TRUE)) {
         return;
     }
     if ((string) $this->display === '') {
         throw new Exception('No display parameter given and no DISPLAY environment variable set.');
     }
     // TODO Check for existence of ffmpeg
     // We need to add "exec" before the actual command to allow the correct termination of a subprocess
     $ffmpeg = new ProcessBuilder(array('exec', $this->pathToFfmpeg, '-y', '-r', $this->frameRate, '-f', 'x11grab', '-s', $this->size, '-i', $this->display, '-vc', 'x264', '-pix_fmt', 'yuv420p', $this->getTmpFilename()));
     $this->captureProcess = $ffmpeg->getProcess();
     $this->captureProcess->start();
     // TODO Check for errors
 }
开发者ID:networkteam,项目名称:behat-capture,代码行数:19,代码来源:FfmpegContext.php

示例15: start

 /**
  * Starts the server process
  *
  * @param Process $process A process object
  *
  * @throws \RuntimeException
  */
 public function start(Process $process = null)
 {
     // Check if the server script exists at given path
     if (false === $this->serverPath || false === is_file($this->serverPath)) {
         throw new \RuntimeException(sprintf("Could not find server script at path '%s'", $this->serverPath));
     }
     // Create process object if neccessary
     if (null === $process) {
         $processBuilder = new ProcessBuilder(array($this->nodeBin, $this->serverPath));
         $process = $processBuilder->getProcess();
     }
     $this->process = $process;
     // Start server process
     $this->process->start();
     $this->connection = null;
     // Wait for the server to start up
     $time = 0;
     $successString = sprintf("server started on %s:%s", $this->host, $this->port);
     while ($this->process->isRunning() && $time < $this->threshold) {
         if ($successString == trim($this->process->getOutput())) {
             $this->connection = new Connection($this->host, $this->port);
             break;
         }
         usleep(1000);
         $time += 1000;
     }
     // Make sure the server is ready or throw an exception otherwise
     $this->checkAvailability();
 }
开发者ID:tillk,项目名称:vufind,代码行数:36,代码来源:Server.php


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