PHP code example of wuzehv / phpmw

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

    

wuzehv / phpmw example snippets




// 继承抽象类
class Test extends \PhpMw\BaseMasterWorker
{
    // 添加任务
    function master()
    {
        for ($i = 0; $i < 200; $i++) {
            $this->addJob($i);
        }
    }

    // 处理任务
    function worker($job)
    {
        usleep(100);
        echo $job, PHP_EOL;
    }
}

$obj = new Test();

// 设置进程数,默认8个
$obj->setWorkerNum(5);

$obj->run();