This is high performance PHP Mutilprocessing Task Manager written in PHP.
-
By using this tool, PHP scripts can be invoked asynchronously based on multi processes, and finally wait for each process to return results, saving lots of time.
-
graceful and efficient
You can use composer to install this library from the command line.
composer require sinacms/multiprocess<?php
use Mutilprocessing\Async;
Async::create()->run('task.php', ['runTest'.$i]);<?php
use Mutilprocessing\Async;
Async::create()->startFunc(function($param1, $param2) {
echo $param1.$param2.PHP_EOL;
}, ['param1' => 'hello', 'param2' => ' world'])
$func = function ($param1, $param2) {
echo "this is an another func";
};
Async::create()->startFunc($func, ['param1' => 'hello', 'param2' => ' PHP']); <?php
use Mutilprocessing\Async;
Async::join(function($code, $out, $err) use(&$outData) {
// var_dump($code, $out, $err);
$outData = $out;
});// please pass $argv[1] to get args
<?php
use Mutilprocessing\Async;
Async::getArgs($argv[1]);<?php
use Mutilprocessing\Async;
Async::discard();- public static function create()
- public static function start($scriptname, $args, $envs = [])
- public function startFunc(callable $function, $args = [])
- public static function discard()
- public static function wait(callable $logHandler = null)
- public static function getArgs($argv = null)