PHP code example of parallel-php / parallel-task

1. Go to this page and download the library: Download parallel-php/parallel-task 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/ */

    

parallel-php / parallel-task example snippets


$workerBuilder = new ExecutorWorkerBuilder()
$worker = $workerBuilder->withConsumeQueue($queue)->buildWorker();
$worker->work($type);

$executorBuilder = new ExecutorWorkerBuilder()
$executor = $executorBuilder->withPublishQueue($queue)->buildExecutor();

$futureResult = $executor->submit($type, MyTask::class, [$param1, $param2]);
//...some other time consuming tasks
$result = $futureResult->getResult();