PHP code example of yoshi2889 / tasks

1. Go to this page and download the library: Download yoshi2889/tasks 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/ */

    

yoshi2889 / tasks example snippets




$loop = React\EventLoop\Factory::create();
$taskController = new \Yoshi2889\Tasks\TaskController($loop);

// A simple callback task, run only once, which will trigger in 10 seconds:
$callbackTask = new \Yoshi2889\Tasks\CallbackTask(function ()
{
	echo 'Hello world!' . PHP_EOL;
}, 10);
// Output (after 10 seconds): Hello world!

$repeatableTask = new \Yoshi2889\Tasks\RepeatableTask($callbackTask, 5);

$repeatableTask->cancel();

$callbackTask = new \Yoshi2889\Tasks\CallbackTask(function ()
{
	echo 'Hello ';
	return new \Yoshi2889\Tasks\CallbackTask(function ()
	{
		echo 'world!' . PHP_EOL;
	}, 5); 
}, 5);
// Output (after 10 seconds): Hello world!