Skip to content

Instantly share code, notes, and snippets.

@jakzal
Last active August 29, 2015 14:02
Show Gist options
  • Save jakzal/a3915d096eca42a69b79 to your computer and use it in GitHub Desktop.
Save jakzal/a3915d096eca42a69b79 to your computer and use it in GitHub Desktop.
PHP Server Behat Context
<?php
use Behat\Behat\Context\Context;
use Symfony\Component\Process\Process;
class PhpServerContext implements Context
{
/**
* @var Process
*/
private static $phpServer;
/**
* @BeforeSuite
*/
public static function startPhpServer()
{
self::$phpServer = new Process('php -S localhost:8000 features/application/index.php');
self::$phpServer->start();
$tries = 10;
while (!($result = @file_get_contents('http://localhost:8000/')) && $tries-- > 0) {
usleep(10000);
}
}
/**
* @AfterSuite
*/
public static function stopPhpServer()
{
self::$phpServer->stop();
}
}
@jakzal
Copy link
Author

jakzal commented Feb 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment