A PHP library providing iteration primitives like map and filter using generators, working with any iterable type.
Iter is a PHP library that provides iteration primitives like map, filter, and reduce using generators. It solves the problem of performing functional operations on any iterable type—not just arrays—while maintaining lazy evaluation for memory efficiency.
PHP developers working with iterators, generators, or functional programming patterns who need consistent iteration utilities across different iterable data structures.
Developers choose Iter because it offers a unified, lazy approach to iteration that works with arrays, traversables, and custom iterators, unlike native PHP array functions or SPL iterators which are more limited in scope.
Iteration primitives using generators
Functions work with arrays, traversables, iterators, and aggregates, unlike native array_map or SPL iterators that are limited, enabling consistent code across data structures.
Operations use PHP generators to process data on-demand, reducing memory usage for large datasets compared to eager array functions that create intermediate arrays.
Includes map, filter, reduce, zip, chain, and over 30 other primitives, providing a wide range of functional iteration tools directly in the library.
Offers makeRewindable and rewindable prefixes to handle multiple passes over generator-based iterators, addressing a common limitation of default generators.
Generators are inherently non-rewindable, requiring extra steps like rewindable wrappers for reuse, which adds complexity compared to native arrays or SPL iterators.
Usage examples are minimal in the README; developers must read the source file iter.php for details, making onboarding harder than with fully documented libraries.
Focuses solely on iteration primitives without advanced functional features like partial application or monadic operations, which might require additional libraries.
Sample code for several design patterns in PHP 8.x
Primitives for functional programming in PHP
A Simple PHP Finite State Machine
League\Pipeline
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.