PHP code example of beauty-framework / parallels

1. Go to this page and download the library: Download beauty-framework/parallels 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/ */

    

beauty-framework / parallels example snippets


use Beauty\Parallels\Concurrent;
use Beauty\Parallels\WorkersName;

$results = Concurrent::run([
    'task-1' => fn() => 1 + 1,
    'task-2' => fn() => strtoupper('hello'),
]);

print_r($results);

[
    'task-1' => 2,
    'task-2' => 'HELLO',
]

Concurrent::run(array $callbacks, int $timeoutSeconds = 10, string $type = WorkersName::FIBER): array

Concurrent::run([
    'a' => fn() => 42,
], 5, WorkersName::FIBER);