Generators in the Real World

Generators are one of the coolest things in modern PHP! They were introduced in PHP v5.5 and expanded even more in PHP 7.  I’ve read a lot about concurrency and how many event loops utilize these generators to interrupt code to do a little bit of everything at (seemingly) the same time.  However, this is not the most useful point of generators in typical PHP applications.  Let’s take a look at a couple ways that Generators can make life easier in typical, synchronous, PHP applications.