php-symfony-doctrine-batch-processing

Batch Doctrine reads and writes to prevent memory exhaustion in Symfony.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/LounisBou/claude-code --skill php-symfony-doctrine-batch-processing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: php-symfony-doctrine-batch-processing
Source: https://github.com/LounisBou/claude-code/tree/main/skills-available/symfony/php-symfony-doctrine-batch-processing
Command: npx skills add https://github.com/LounisBou/claude-code --skill php-symfony-doctrine-batch-processing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Processing large numbers of Doctrine entities in Symfony can exhaust memory and slow down apps. This skill provides a memory-efficient batching approach that processes items in chunks with periodic flush/clear.

Core Features & Use Cases

  • Iterative processing with toIterable() to avoid loading all results
  • Periodic EntityManager clear and flush to manage memory during long-running jobs
  • Flexible batching strategies (ID-based pagination, batch sizes, and DBAL for bulk updates)

Quick Start

Run a Symfony command that processes unprocessed Product entities in batches of 100, flushing and clearing memory periodically.

Frequently Asked Questions about php-symfony-doctrine-batch-processing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I batch process large Doctrine datasets in Symfony without running out of memory?

Batch processing large Doctrine datasets requires iterative reads with toIterable() and periodic EntityManager flush/clear cycles. This approach prevents memory exhaustion by processing items in chunks and clearing the identity map between batches.

Why does Doctrine ORM exhaust memory during bulk updates?

Doctrine ORM exhausts memory during bulk updates because EntityManager tracks every loaded entity in its identity map. Without periodic clear calls, processing thousands of rows accumulates managed objects until PHP hits its memory limit.

Can I use DBAL instead of Doctrine ORM for bulk data updates?

Yes, DBAL can be used as a flexible batching strategy for bulk data updates. It bypasses Doctrine ORM object tracking overhead entirely, providing a memory-efficient alternative for direct database modifications like mass price changes.

What is the best way to iterate over millions of rows in a Symfony command?

The best way to iterate over millions of rows is using Doctrine toIterable() with ID-based pagination. Combined with periodic flush and clear operations inside a Symfony command, it manages memory effectively during long-running batch jobs.

When should I not use Doctrine ORM for batch processing?

You should avoid Doctrine ORM for batch processing when handling millions of rows where object hydration is unnecessary. For pure bulk updates without business logic, DBAL alternatives bypass object tracking overhead and perform significantly better.