1. Go to this page and download the library: Download ssigwart/process-pool library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use ssigwart\ProcessPool\ProcessPoolProcess;
use ssigwart\ProcessPool\ProcessPoolProcessMessageHandlerInterface;
/** My example process */
class MyExampleProcess implements ProcessPoolProcessMessageHandlerInterface
{
/**
* Handle exit request
*/
public function handleExit()
{
// You can do cleanup here, then call exit
print 'Existing now.' . PHP_EOL;
exit;
}
/**
* Handle request
*
* @param string $data Data
*/
public function handleRequest(string $data)
{
// Handle $data here
// Anything you output will be returned as STDOUT
print 'You sent data ' . $data . PHP_EOL;
// You can use error_log to output to STDERR
error_log('This will be returned as STDERR.');
}
}
$proc = new ProcessPoolProcess(new MyExampleProcess());
$proc->handleMessages();