Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Use the Requests lib to wait for the built-in PHP server to start up
<?php
$process = new Process( sprintf( 'php -S localhost:8080 -t %s', __DIR__ ) );
$process->start();
$start = time();
// Wait for the server to start up (5 seconds max).
do {
try {
Requests::get( 'http://localhost:8080' );
} catch ( Requests_Exception $e ) {
continue;
}
break;
} 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