2017 © Pedro Peláez

library phplib-lightprocessexecutor

A PHP 5.4 process executor implementation.



A PHP 5.4 process executor implementation.

  • Friday, March 20, 2015
  • by xilon.jul
  • Repository
  • 0 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown



Php asynchronous multi-processing library, (*1)

  • Forking capabilities
  • Asynchronous event handling via libevent
  • The routing uses a flood-like algo to route messages accross a tree of processes
  • Internal process communication via socket pairs A message is any type of payload and can be unicast or broadcast. There is currently no multicast support (aka group). Thus it can be achieved via aliasing processes before fork, it was not made for this purpose
  • Application developper are responsible for defining listeners and writing their own application code.
use LightProcessExecutor\Event\MessageEvent;

use LightProcessExecutor\EventListener\RouterEventListener;

use LightProcessExecutor\LightProcessExecutor;

declare(ticks=1) ;
require __DIR__ . '/vendor/autoload.php';

// Define a simple router listener
class TestListener implements RouterEventListener {

        public function onInterruptReceive(MessageEvent $e){
          // Not to be used, the urgent flag in the routing protocol is obsolete and <b>should NOT</b> be used

        public function onPeerShutdown(LightProcessExecutor $executor, $pid, array $lostMessages){
          // invoked when a peer shuts down (the peer is necessarily connected to the process receiving the event)

        public function onMessageReceived(MessageEvent $e){
            // invoked when a message is received 

        public function onMessageSent(MessageEvent $e){
          // invoked when this process has fully written its message to the targeted peers

        public function onRouterError($operation, $errno, $errstr, \Exception $e = NULL){
          // invoked when the router raises an error that the application programmer might want to handle

        public function getPriority(){
            return 0;

$root = new LightProcessExecutor();
$root->addRouterMessageListener(new TestListener());
// Might want to fork processes here
$pid2 = $root->fork("", null, function($executor){
$root->submit("test", null, false, false, true);
$root->submit("for pid2 only", $pid2);

The Versions

20/03 2015



A PHP 5.4 process executor implementation.

  Sources   Download


process fork ipc mutli-process

16/02 2015


A PHP 5.4 process executor implementation.

  Sources   Download


process fork ipc mutli-process