PHPackages                             mhitza/file-enumerators - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. mhitza/file-enumerators

AbandonedArchivedLibrary[File &amp; Storage](/categories/file-storage)

mhitza/file-enumerators
=======================

File streaming and preprocessing library (via generators)

1.3.0(10y ago)0606Apache-2.0PHPPHP &gt;=5.5.0

Since Dec 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/mhitza/file-enumerators)[ Packagist](https://packagist.org/packages/mhitza/file-enumerators)[ RSS](/packages/mhitza-file-enumerators/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

File Enumerators
================

[](#file-enumerators)

[![Build Status](https://camo.githubusercontent.com/953d0bcdea6600fe3d6d124801e11bb0ff6057e52ae651e06c30e228c53daa38/68747470733a2f2f7472617669732d63692e6f72672f6d6869747a612f66696c652d656e756d657261746f72732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mhitza/file-enumerators)[![Code Climate](https://camo.githubusercontent.com/81119d5492f5f61f80230c291c872051af1209d53a91bc89b2412ae94e27b089/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d6869747a612f66696c652d656e756d657261746f72732f6261646765732f6770612e737667)](https://codeclimate.com/github/mhitza/file-enumerators)[![Test Coverage](https://camo.githubusercontent.com/ae015e8226ae6d04fec7b8e05dc15fbf0fd2954bc7e782b37b4873abb452c1fb/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d6869747a612f66696c652d656e756d657261746f72732f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/mhitza/file-enumerators)[![SensioLabsInsight](https://camo.githubusercontent.com/2a87fdc073df2da325273c7f0495f1b789b553a90aeed47a97be2e104e8e2adc/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f38303465353230612d333734352d346135652d383833362d3137636362656161393464332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/804e520a-3745-4a5e-8836-17ccbeaa94d3)

File streaming library (via generators), for line by line readers and CSV parsing (other specializations may come up at some point).

It's important to remember that **generators are forward-only iterators**. For that you should take note that in the example code I'm calling `enumerate()` inside the `foreach` construct instead of assigning it to a variable, and iterating over that variable. That is the safe way of iterating over a generator, since `enumerate()` is the `Generator` builder, UNLESS you want to constrain single passes over the streams, in which case binding the generator to a variable is prefered.

Install
-------

[](#install)

Available as a [composer package](https://packagist.org/packages/mhitza/file-enumerators), **requires** PHP `>=5.5.0`

```
$ composer.phar require mhitza/file-enumerators
```

Example usage
-------------

[](#example-usage)

### Line by line reader

[](#line-by-line-reader)

a.k.a. how the classic fgets function usage translates in this library

```
