1. Go to this page and download the library: Download carno-php/coroutine 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/ */
carno-php / coroutine example snippets
function go(mixed $program, Context $ctx = null) : void
yield (function () {
yield defer(function ($stage) {
// $stage is returned value or last yield value or throwable if exception
echo 'in defer', PHP_EOL;
});
echo 'in end', PHP_EOL;
})();