PHP code example of gowork / throttler

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

    

gowork / throttler example snippets


use GW\Throttler\Throttler;

$throttler = new Throttler(1.0);

foreach ($heavyTasks->all() as $task) {
    $throttler->throttle(); // wait a second... before next task
    $task->run();
}

use GW\Throttler\Throttler;

$throttledTask = Throttler::iterable($heavyTasks->all(), 1.0);

foreach ($throttledTask as $task) {
    $task->run(); // for each iteration it will sleep one second
}