The idea of this package is to make it easier to work with iterable data as streams
I find myself exporting data to the file system and using flysystem's writeStream. This becomes an issue when you don't have much local storage to write large exports to.
So my first iteration was pretty ugly (but worked), but then I saw what Guzzle's PSR-7 package did with StreamWrapper and using PSR-7 and figured I could refactor my app to use PSR-7.
My second iteration worked, but still assumed the export was a specific file type (csv).
When I had the requirements to stream JSON, I decided to refactor a little again by adding
the ability to add a formatter decorator.
$iterable = [
['first' => 'Jim', 'last' => 'Thompson', 'month' => 'April'],
['first' => 'Tim', 'last' => 'Johnson', 'month' => 'December']
];
$formatter = new KJLJon\StreamingIterable\Formatter\CsvFormatter();
$stream = new KJLJon\StreamingIterable\IterableToReaderStream($iterable, $formatter);
$fp = KJLJon\StreamingIterable\StreamWrapper::getResource($stream);
//do something with stream (IE: flyweight's writeStream($location, $fp);
fpassthru($fp);
fclose($fp);
Please open an issue and/or pull request