PHP code example of kalibora / chunk-generator

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

    

kalibora / chunk-generator example snippets


use Kalibora\ChunkGenerator\ChunkGeneratorBuilder;

$fooRepository = $manager->getRepository(Foo::class);
$qb = $fooRepository->createQueryBuilder('f');
$gen = ChunkGeneratorBuilder::fromDoctrineQueryBuilder($qb)->setChunkSize(200)->build();

// Iterate all foo entity. Fetch 200 records at a time and clear it.
foreach ($gen() as $foo) {
    echo $foo->getVar(), PHP_EOL;
}