Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Use the Requests lib to wait for the built-in PHP server to start up
$process = new Process( sprintf( 'php -S localhost:8080 -t %s', __DIR__ ) );
$start = time();
// Wait for the server to start up (5 seconds max).
do {
try {
Requests::get( 'http://localhost:8080' );
} catch ( Requests_Exception $e ) {
} while ( time() - $start < 5 );
Requests::get( 'http://localhost:8080/test.php' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment