Download the PHP package setono/doctrine-orm-batcher without Composer
On this page you can find all versions of the php package setono/doctrine-orm-batcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download setono/doctrine-orm-batcher
More information about setono/doctrine-orm-batcher
Files in setono/doctrine-orm-batcher
Package doctrine-orm-batcher
Short Description A library for processing large collections in Doctrine
License MIT
Informations about the package doctrine-orm-batcher
Doctrine ORM Batcher library
Use this library when you need to process large amounts of entities and maybe in an asynchronous way.
Why do we need this library? Why not just use a paginator library like Pagerfanta or normal batch processing in Doctrine?
Well, because MySQL is not very good with LIMIT and OFFSET when the tables become too large. As for Doctrine batch processing capabilities the difference is that this library is very opinionated. It will work very well in a message based architecture where large processing will likely be done in an asynchronous way.
How does it work then? It uses the seek method to paginate results instead.
Installation
Usage
There are two ways to get results: Getting a range of ids or getting a collection (either of ids or entities).
Range of ids
A range is a lower and upper bound of ids. This is typically intended to be used in an asynchronous environment where you will dispatch a message with the lower and upper bounds so that the consumer of that message will be able to easily fetch the respective entities based on these bounds.
Example
You want to process all your Product
entities. A query builder for that would look like:
Now inject that query builder into the id range batcher and dispatch a message:
Then sometime somewhere a consumer will receive that message and process the products:
This approach is extremely fast, but if you have complex queries it may be easier to use the collection batchers.
Collection of ids
Should be used for async handling of sets that selected with complex queries.
Example
You want to process only enabled Product
entities.
Then sometime somewhere a consumer will receive that message and process the products:
Collection of objects
Should be used for immediate handing objects that selected with complex queries.
Example
You want to immediately process only enabled Product
entities.
Framework integration
All versions of doctrine-orm-batcher with dependencies
doctrine/collections Version ^1.6 || ^2.0
doctrine/orm Version ^2.8 || ^3.0
doctrine/persistence Version ^1.3 || ^2.1 || ^3.0
symfony/property-access Version ^5.4 || ^6.0
webmozart/assert Version ^1.10