1. Go to this page and download the library: Download clue/promise-timeout 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/ */
clue / promise-timeout example snippets
React\Promise\Timer\timeout(…);
use function React\Promise\Timer\timeout;
timeout(…);
use React\Promise\Timer;
Timer\timeout(…);
$promise = accessSomeRemoteResource();
React\Promise\Timer\timeout($promise, 10.0)->then(function ($value) {
// the operation finished within 10.0 seconds
});
$promise = accessSomeRemoteResource();
React\Promise\Timer\timeout($promise, 10.0)->then(
function ($value) {
// the operation finished within 10.0 seconds
},
function ($error) {
if ($error instanceof React\Promise\Timer\TimeoutException) {
// the operation has failed due to a timeout
} else {
// the input operation has failed due to some other error
}
}
);
React\Promise\Timer\timeout($promise, 10.0)->then(function ($value) {
// the operation finished within 10.0 seconds
})->catch(function (React\Promise\Timer\TimeoutException $error) {
// the operation has failed due to a timeout
})->catch(function (Throwable $error) {
// the input operation has failed due to some other error
});