當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。