PHP code example of reactphp-x / process-manager
1. Go to this page and download the library: Download reactphp-x/process-manager 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/ */
reactphp-x / process-manager example snippets
use ReactphpX\ProcessManager\ProcessManager;
ProcessManager::$debug = true;
$stream = ProcessManager::instance('cron')->call(function($stream) {
return 'hello world cron';
});
$stream->on('data', function($data) {
echo $data.PHP_EOL;
});
$stream->on('close', function() {
echo 'closed'.PHP_EOL;
});
use ReactphpX\ProcessManager\ProcessManager;
ProcessManager::$debug = true;
$stream = ProcessManager::instance('queue')->call(function($stream) {
return 'hello world queue';
});
$stream->on('data', function($data) {
echo $data.PHP_EOL;
});
$stream->on('close', function() {
echo 'closed'.PHP_EOL;
});
// see example/02.php
ProcessManager::instance('queue')->setBootFile(__DIR__.'/boot.php');
ProcessManager::instance('queue')->setNumber(10);
$stream = ProcessManager::instance('queue')->call(function($stream) {
return 'hello world queue';
});
$stream->on('data', function($data) {
echo $data.PHP_EOL;
});
$stream->on('close', function() {
echo 'closed'.PHP_EOL;
});
var_dump(ProcessManager::instance('queue')->getInfo());