Interators + Generatiors: The Road to Virtual Infinite RAM
summary
Explains how PHP iterators and generators let code traverse huge collections without loading them into RAM, showing practical combos like InfiniteIterator + LimitIterator to stream 10+ days or terabyte CSVs, and using yield from for adapter delegation. Reports benchmarks: generators run up to 40% faster vs native range and up to 400% faster vs iterator implementations. Cites real uses (Symfony Console, Finder, HTTP Foundation, Doctrine twoIterable, a custom LStream uploader), shows getReturn() for counts and points to Zen generator internals.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 3:40What is a collection
- 6:32Iterator design pattern
- 10:26Implementing iterators in PHP
- 13:00Advanced SPL iterators
- 16:37Generators and infinite RAM
- 18:04Creating generators in PHP
- 22:22Delegated generation
- 25:41Optimizing bottlenecks
- 27:27Performance benefits
- 29:34Generators in libraries
- 32:49Why use generators








