This example shows how to process kafka messages in batches with php-rdkafka. As soon as the required number of messages appears in topic, they will be immediately processed.
The key Kafka Conf value to achieve proper behavior is enable.auto.offset.store=false
. See here
PARTITION=0