PHP code example of pbergman / fork
1. Go to this page and download the library: Download pbergman/fork 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/ */
pbergman / fork example snippets
$m = new \PBergman\Fork\Manager();
$m->setWorkers(10);
for ($i = 0; $i < 25; $i++) {
$foo = rand(1,8);
$m->addJob(function($redis, $logger) use ($foo) {
$logger->info('sleeping ' . $foo);
sleep($foo);
});
}
$m->run();