PHP code example of xwp / wait-for
1. Go to this page and download the library: Download xwp/wait-for library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xwp / wait-for example snippets
// Include the Composer autoloader.
_Connection( 'localhost', 3306 );
try {
$connection->connect( 30 );
} catch ( Exception $e ) {
trigger_error( $e->getMessage(), E_USER_ERROR );
}
use XWP\Wait_For\With_Retry;
$runner = new With_Retry(
function() {
// Do something here.
return false;
}
);
if ( ! $runner->run( 10 ) ) {
trigger_error( 'Failed to connect!' );
}