PHP code example of cathy / thinkphp6-async-task
1. Go to this page and download the library: Download cathy/thinkphp6-async-task 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/ */
cathy / thinkphp6-async-task example snippets
namespace app\tasks;
use cathy\AsyncTask\main\AsyncTaskSynchronizer;
class DemoAsyncTasks
{
public function demo($data, AsyncTaskSynchronizer $taskSynchronizer) {
for($i = 1;$i <= 100; $i++) {
$taskSynchronizer->update($i);
sleep(1);
}
$taskSynchronizer->done(['message'=>'Hi!'.$data['name']]);
}