PHP code example of wgqi1126 / swoole-worker

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

    

wgqi1126 / swoole-worker example snippets




use Wgqi1126\SwooleWorker\SwooleJob;
use Swoole\Coroutine\Channel;
use Wgqi1126\SwooleWorker\SwooleWorker;

n";
        for ($i = 0; $i < 100; $i++) $channel->push($i);
    }

    public function worker($data = null)
    {
        print "worker-{$data}\n";
        sleep(1);
    }
};
$worker = new SwooleWorker($job);
$worker->run();