1. Go to this page and download the library: Download mrden/forker 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/ */
mrden / forker example snippets
$context = 'any parent code context data';
$callable = new \Mrden\Forker\Process\CallableProcess(static function () use ($context) {
echo 'context from parent process ' . $context;
});
$forker = new \Mrden\Forker\Forker($callable);
$forker->run();
// any code in this parent process
namespace Any;
class SingleProcess extends \Mrden\Forker\Contracts\Process
{
use \Mrden\Forker\Traits\ProcessFileStorageTrait;
public function execute(): void
{
echo 'context from parent process ' . ($this->params['context'] ?? '');
}
protected function prepare(): void
{
}
protected function checkParams(): void
{
}
}
$context = 'any parent code context data';
$singleProcess = new \Any\SingleProcess([
'context' => $context
]);
$forker = new \Mrden\Forker\Forker($singleProcess);
$forker->run(3);
// any code in this parent process
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.