2017 © Pedro Peláez
 

library process

PHP for asynchronous task execution

image

phasty/process

PHP for asynchronous task execution

  • Wednesday, March 9, 2016
  • by dedestr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6,765 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

Process

Allows you make any job in another php-process with ability to get feedback from child process during all execution time:, (*1)

// Child process code:
use Phasty\process\Child\CallableClass;
class ChildProcess extends CallableClass {
    public $property = "A";
    public function doAsyncJob($arg1, $arg2) {
        $this->trigger("doneJob", (object)[ "result" => $arg1 . $arg2  . $this->property ]);
    }
}

And parent process code:, (*2)

use Phasty\Stream\StreamSet;
use Phasty\Process\Child\Controller;

$process = new Controller(ChildProcess::getClass());
/*
  or you can use instance of class ChildProcess with predefined state like this:
  $childJob = new ChildProcess;
  $childJob->property = "B";
  $process = new Controller($childJob);
 */

$process->on("start", function () {
    echo "Child process started\n";
});

$process->on("stop", function () {
    echo "Child process stopped\n";
});

$process->on("doneJob", function ($event) {
    echo "Got result from child: " . $event->getData()->result . "\n";
});

$process->doAsyncJob("foo", "bar");

StreamSet::instance()->listen();
echo "stopped\n";

After execution you should see:, (*3)

Child process started
Got result from child: foobarA
Child process stopped
stopped

You can receive event "error" in parent process on child object in case of catchable error occured or signal (including SIGTERM, SIGFAULT etc), (*4)

Coming soon:

~~1. Killing process with $process->kill();~~, (*5)

~~2. Getting result code~~, (*6)

  1. Bi-directional link (sending commands to child)

~~4. Getting stop reason (normal, signals like segmentation fault and so on)~~, (*7)

The Versions

09/03 2016

dev-master

9999999-dev

PHP for asynchronous task execution

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Cheremnykh

php task process

09/03 2016

0.2.3

0.2.3.0

PHP for asynchronous task execution

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Cheremnykh

php task process

29/12 2015

0.2.2

0.2.2.0

PHP for asynchronous task execution

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Cheremnykh

php task process

14/12 2015

0.2.1

0.2.1.0

PHP for asynchronous task execution

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Cheremnykh

php task process

11/12 2015

0.2.0

0.2.0.0

PHP for asynchronous task execution

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Cheremnykh

php task process

04/09 2014

0.1.1

0.1.1.0

PHP for asynchronous task execution

  Sources   Download

MIT

The Requires

 

The Development Requires

by Dmitry Cheremnykh

php task process