1. Go to this page and download the library: Download clue/block-react 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 / block-react example snippets
// old
$result = Clue\React\Block\await($promise);
// new
$result = React\Async\await($promise);
function blockingExample()
{
// this example uses an HTTP client
// this could be pretty much everything that binds to an event loop
$browser = new React\Http\Browser();
// set up two parallel requests
$request1 = $browser->get('http://www.google.com/');
$request2 = $browser->get('http://www.google.co.uk/');
// keep the loop running (i.e. block) until the first response arrives
$fasterResponse = Clue\React\Block\awaitAny(array($request1, $request2));
return $fasterResponse->getBody();
}