1. Go to this page and download the library: Download arara/process 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/ */
arara / process example snippets
declare(ticks=1);
use Arara\Process\Action\Callback;
$callback = new Callback(function () {
echo "This will be executed in the background!" . PHP_EOL;
});
$callback->bind(Callback::EVENT_SUCCESS, function () {
echo "This will be executed if the action callback was successful!" . PHP_EOL;
});
$callback->bind(Callback::EVENT_ERROR | Callback::EVENT_FAILURE, function () {
echo "It is going to be executed if the action fails or get an error" . PHP_EOL;
});
$command = new Command('whoami');
$command = new Command('cp', array('/path/to/source', '/path/to/destination'));
$control = new Control();
$pid = $control->fork();// Throws RuntimeException when pcntl_fork() returns -1
if ($pid > 0) {
echo 'Waiting on child...' . PHP_EOL;
$control->waitProcessId($pid);
echo 'Child finished' . PHP_EOL;
$control->quit();
}
echo 'Child process has PID ' . $control->info()->getId() . PHP_EOL;
echo 'Child process has parent PID ' . $control->info()->getParentId() . PHP_EOL;
$control->flush(2.5); // Will try to flush current process memory and sleep by 2 and a half seconds
$control->signal()->send('kill'); // Will send SIGKILL to the current process (the child)
$control = new Control();
$applicationName = 'my_app';
$pidfile = new Pidfile($control, $applicationName);
$pidfile->initialize();
// Whatever you need here...
$pidfile->finalize();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.