1. Go to this page and download the library: Download cclilshy/p-ripple-core 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/ */
cclilshy / p-ripple-core example snippets
\Co\async(static function (){
\Co\sleep(1);
echo 'Coroutine 1' , PHP_EOL;
});
\Co\async(static function (){
\Co\sleep(1);
echo 'Coroutine 2' , PHP_EOL;
});
\Co\async(static function (){
\Co\sleep(1);
echo 'Coroutine 3' , PHP_EOL;
});
\Co\sleep(2); // Wait for all coroutines to complete execution
use GuzzleHttp\Exception\GuzzleException;
use Psc\Utils\Output;
$client = Co\Plugin::Guzzle()->newClient();
for ($i = 0; $i < 10; $i++) {
\Co\async(static function (){
try {
$response = $client->get('https://www.google.com/');
echo $response->getStatusCode(), \PHP_EOL;
} catch (GuzzleException $e) {
Output::exception($e);
}
});
}
\Co\wait();