QPM Docs - Comos/qpm GitHub Wiki

Overview

QPM’s full name is Quick Process Management Framework in PHP. PHP is so powerful in web development, that people always forget that it could be used to write strong CLI programs, even the daemon programs. The process management is just the core of daemon programming. QPM is such a library to simplify the process management.

A multi-process CLI program used QPM looks like following:

<?php
$worker1 = function() {
  while(true) {
    echo “#mission 1, pid:".posix_getpid()."\n";
      sleep(3);
  }
};
$worker2 = function() {
  while(true) {
    echo “*mission 1, pid:".posix_getpid()."\n";
      sleep(3);
  }
};
$config = [
 ['worker'=>$worker1],
 ['worker'=>$worker2, 'quantity'=>2]
];
/* 
   The worker1 would run in a child process.
   At the same time, the worker2 would run in other two child processes concurrently.
   As a worker exits, a same worker would be started, again and again. 
   It’s just the one-for-one mode. 
*/
Comos\Qpm\Supervision\Supervisor::multiGroupOneForOne($config)->start();

QPM capsulates the pcntl_fork() as OOP style to promote readability. As for the supervisor, could help developers writing robust multi-process programs easily.

In future versions, we plan to add signal handling and cross-process communication modules.

Guides

#References