Download the PHP package fsc/batch without Composer
On this page you can find all versions of the php package fsc/batch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package batch
FSCBatch
PHP 5.3 library to help you run huge batch.
It takes a PagerfantaAdapterInterface (doctrine orm, propel, array, solarium etc... available) as a data source, will get data in slice of the size of the batch size, and will then process each context in batch by calling the callback you provided.
Features:
- Evented system using the symfony2 event dispatcher, to easily be able to add behaviors
Included listeners:
- ProgressEventListener: Displays progress, elapsed time and estimated remaining time at the end of each batch.
- DoctrineEventListener: at the end of each batch:
- flush() the object manager, to save everything at the same time (may improve performance in some cases)
- clear() the object manager, to avoid memory leaks
Extra:
- Add a
PagerfantaAdapter
for doctrine ORM, that traverse the table using range queries on the id instead of LIMIT/OFFSET. LIMIT/OFFSET degrades query time as the OFFSET grows, wheareas range queries time stay consistent.
Be aware that this library is a WIP, and requires more tests.
Examples
Simple batch
Would output
Doctrine ORM Batch in a symfony command
This example uses the DoctrineEventListener, which flush (save everything) and clears the objectManager (avoid memory problems) at the end of each batch.
We also use a custom PagerfantaAdapter: DoctrineBatchAdapter
, that uses range queries (id > 100 AND id < 200) instead of LIMIT/OFFSET to avoid increasing query time as the OFFSET grows.
All versions of batch with dependencies
pagerfanta/pagerfanta Version dev-master
symfony/event-dispatcher Version >=2.1