PHP code example of symfony-bundles / fork

1. Go to this page and download the library: Download symfony-bundles/fork 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/ */

    

symfony-bundles / fork example snippets

 php
use SymfonyBundles\Fork;

$fork = new Fork\Fork();
 php
namespace AppBundle\Task;

use SymfonyBundles\Fork\TaskInterface;

class DemoTask implements TaskInterface
{
    public function execute()
    {
        echo "Hello World!\n";
    }
}
 php
use AppBundle\Task\DemoTask;

$task = new DemoTask();

$fork->attach($task)->run(4)->wait(); // 4 - this is number of subprocesses