sinacms/multiprocess

a tool for PHP multi process asynchronous tasks manage


Keywords
php, async, asynchronous, multi process
License
Apache-2.0

Documentation

PHP Mutilprocessing

This is high performance PHP Mutilprocessing Task Manager written in PHP.

Contents

Feature

  • 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

Installation

You can use composer to install this library from the command line.

composer require sinacms/multiprocess

Usage

distribute tasks and async execute

<?php

use Mutilprocessing\Async;

Async::create()->run('task.php', ['runTest'.$i]);

sync wait for all process end

<?php

use Mutilprocessing\Async;

Async::join(function($code, $out, $err) use(&$outData) {
//    var_dump($code, $out, $err);
    $outData = $out;
});

clean all task

<?php

use Mutilprocessing\Async;

Async::discard();

Documentation

  • Async

  • option shorthand

  • public static function create()
  • public static function run($scriptname, $args, $envs = [])
  • public static function discard()
  • public static function join(callable $logHandler = null)