Created
August 30, 2019 16:45
-
-
Save frankiejarrett/c800cb0abf8af95c6c1f3cd7a2381011 to your computer and use it in GitHub Desktop.
Use the Requests lib to wait for the built-in PHP server to start up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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