PHP code example of kompakt / collection-runner

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

    

kompakt / collection-runner example snippets


use Kompakt\CollectionRunner\Console\Subscriber\Debugger;
use Kompakt\CollectionRunner\Runner;
use Kompakt\CollectionRunner\EventNames;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\EventDispatcher\EventDispatcher;

$dispatcher = new EventDispatcher();
$eventNames = new EventNames();
$runner = new Runner($dispatcher, $eventNames);
$debugger = new Debugger($dispatcher, $eventNames);
$debugger->activate(new ConsoleOutput());

$countries = [
    'Andorra',
    'Austria',
    'Australia',
    'Brazil',
    'Chile',
    'Cuba',
    'Germany',
    'Finland',
    'France',
    'Guatemala',
    'Italy',
    'Lebanon',
    'Morocco',
    'Nepal',
    'Russia',
    'Switzerland',
    'Thailand'
];

$getCountriesCallable = function($first, $max) use ($countries)
{
    return array_slice($countries, $first, $max);
};

$runner->run(count($countries), $getCountriesCallable, 5);