1. Go to this page and download the library: Download fyre/promise 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/ */
use \Fyre\Promise\AsyncPromise;
$promise = new AsyncPromise(function(Closure $resolve, Closure $reject): void {
// this will be executed on a forked process
sleep(3);
$resolve(1);
})->then(function(int $value): void {
// this will be executed on the main thread
echo $value;
});
$promise->wait();