1. Go to this page and download the library: Download intermezzon/asyncprocess 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/ */
intermezzon / asyncprocess example snippets
$pool = new \Intermezzon\AsyncProcess\Pool();
$pool->addCommand('php -r "echo \"Start process.\"; sleep(2); echo \"Process ended\";"');
// Wait for all commands to be done
$pool->executeAndWait();
$pool = new \Intermezzon\AsyncProcess\Pool();
$pool->addCommand('php -r "echo \"Start process 1.\n\"; sleep(2); echo \"Process 1 ended\n\";"');
$pool->addCommand('php -r "echo \"Start process 2.\n\"; sleep(1); echo \"Process 2 ended\n\";"');
// Wait for all commands to be done
$pool->executeAndWait();
$pool = new \Intermezzon\AsyncProcess\Pool();
$pool->addCommand('my_program')
->started(function ($command)) {
echo "Process has started\n";
})
->output(function ($command, $output) {
echo "Process outputed:" . $output . "\n";
// Send stuff to process stdin
$command->input("send this input to process stdin");
})
->error(function ($command, $error) {
echo "Process send error: " . $error ."\n";
})
->ended(function ($command, $exitCode) {
echo "Process ended with exit code: " . $exitCode . "\n";
echo "Process took " . $command->totalTime . " seconds to execute.";
});
// Wait for all commands to be done
$pool->executeAndWait();
$pool = new \Intermezzon\AsyncProcess\Pool();
$pool->setMaxProcesses(3);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.