1. Go to this page and download the library: Download pardnchiu/async 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/ */
pardnchiu / async example snippets
use PD\Async;
$tasks = [
'task1' => [
'method' => function () {
return 'result1';
},
'tasks' => [],
],
'task2' => [
'method' => function () {
return 'result2';
},
'tasks' => ['task1'], // Run after task1
],
'task3' => [
'method' => function () {
return 'result3';
},
'tasks' => ['task1'], // Run after task1
],
'task4' => [
'method' => function () {
return 'result3';
},
'tasks' => ['task2'], // Run after task2
],
];
Async::run($tasks)
->then(function ($results) {
print_r($results);
})
->catch(function ($error) {
echo 'Error: ' . $error->getMessage();
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.