PHPackages                             jotaelesalinas/php-rwgen - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jotaelesalinas/php-rwgen

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jotaelesalinas/php-rwgen
========================

Read/write generators in PHP

v0.5.1(7y ago)0200MITPHPPHP &gt;=5.5CI failing

Since Aug 20Pushed 2w ago1 watchersCompare

[ Source](https://github.com/jotaelesalinas/php-generators)[ Packagist](https://packagist.org/packages/jotaelesalinas/php-rwgen)[ Docs](https://github.com/jotaelesalinas/php-rwgen)[ RSS](/packages/jotaelesalinas-php-rwgen/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (5)Versions (19)Used By (0)

php-data-streams
================

[](#php-data-streams)

\[!IMPORTANT\] This is a breaking v2 release and is not compatible with the old `jotaelesalinas/php-rwgen` package. The package name, namespace, and public API have changed.

[![License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://opensource.org/licenses/MIT)[![CI](https://camo.githubusercontent.com/922acc12b8a00c48199fc3a29dd49242785675ac39c22b6fffd623a4e6ee8a49/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a6f7461656c6573616c696e61732f7068702d646174612d73747265616d732f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/jotaelesalinas/php-data-streams/actions/workflows/ci.yml)

`php-data-streams` is a PHP streaming library for reading and writing large CSV, JSON, XML, XLSX, KML, HTTP and database-backed records without loading everything into memory.

It is designed for data pipelines, import/export jobs, CLI tools and integrations where you want small, explicit reader and writer abstractions instead of heavyweight framework-specific layers.

What it solves
--------------

[](#what-it-solves)

- Process large files and responses record by record.
- Keep memory usage predictable while iterating through data.
- Compose simple readers and writers around generators and iterables.
- Reuse a shared contract across multiple formats.

How This Repository Is Organized
--------------------------------

[](#how-this-repository-is-organized)

This project is a monorepo split into several smaller packages.

That means the repository contains multiple packages in one place, but you do not need to install all of them. Install only the package or packages you actually need.

For example:

- If you only work with CSV files, install the CSV package.
- If you only need JSON Lines, install the JSON package.
- If you want the shared reader and writer interfaces for your own code, install the core package.

Packages
--------

[](#packages)

- [`core`](packages/core/README.md) for the shared `Reader` and `Writer` contracts.
- [`csv`](packages/csv/README.md) for CSV and TSV readers and writers.
- [`json`](packages/json/README.md) for JSON, JSON arrays and NDJSON / JSON Lines.
- [`xml`](packages/xml/README.md) for lazy XML readers and streaming XML writers.
- [`kml`](packages/kml/README.md) for KML output built on XML.
- [`pdo`](packages/pdo/README.md) for database cursor helpers.
- [`http`](packages/http/README.md) for line and page-oriented HTTP streams.
- [`excel`](packages/excel/README.md) for minimal XLSX sheet readers.

Quick Example
-------------

[](#quick-example)

```
use JLSalinas\DataStreams\Csv\CsvReader;

$reader = new CsvReader(__DIR__ . '/customers.csv');

foreach ($reader as $customer) {
    echo $customer['name'] . PHP_EOL;
}
```

Installation
------------

[](#installation)

Install the package you need via Composer. For example, to work with CSV files:

```
composer require jotaelesalinas/php-data-streams-csv
```

If you want to work with JSON Lines:

```
composer require jotaelesalinas/php-data-streams-json
```

If you want to build your own reader or writer and only need the shared interfaces:

```
composer require jotaelesalinas/php-data-streams-core
```

You can also install more than one package if your project needs them.

Example Usage
-------------

[](#example-usage)

### CSV reader

[](#csv-reader)

```
use JLSalinas\DataStreams\Csv\CsvReader;

$reader = new CsvReader(__DIR__ . '/customers.csv');

foreach ($reader as $customer) {
    echo $customer['name'] . PHP_EOL;
}
```

### CSV writer

[](#csv-writer)

```
use JLSalinas\DataStreams\Csv\CsvWriter;

$writer = new CsvWriter(__DIR__ . '/export.csv');
$writer->write(['name' => 'Ada', 'email' => 'ada@example.com']);
$writer->write(['name' => 'Grace', 'email' => 'grace@example.com']);
$writer->close();
```

### JSON reader

[](#json-reader)

```
use JLSalinas\DataStreams\Json\JsonReader;

$reader = new JsonReader(__DIR__ . '/events.ndjson');

foreach ($reader as $event) {
    var_dump($event);
}
```

Typical Use Cases
-----------------

[](#typical-use-cases)

- CSV/TSV imports and exports.
- JSON Lines ingestion and generation.
- XML feeds and document-to-record transforms.
- XLSX sheet reading in long-running jobs.
- KML generation from geospatial records.
- Streaming database results and HTTP responses.

Updating from v1.x
------------------

[](#updating-from-v1x)

If you are coming from `jotaelesalinas/php-rwgen`, review these changes before moving your code to this release:

- Switch Composer to the package you actually use. For example:

    ```
    composer remove jotaelesalinas/php-rwgen
    composer require jotaelesalinas/php-data-streams-csv
    ```

    If your project uses multiple formats, install the matching subpackages.
- Update the namespace imports. For example:

    ```
    use JLSalinas\RWGen\CsvReader;
    ```

    becomes:

    ```
    use JLSalinas\DataStreams\Csv\CsvReader;
    ```
- If you previously relied on the monolithic package, move each reader or writer to the matching subpackage. For example, CSV streaming now lives in `packages/csv`, while the shared contracts live in `packages/core`.
- Recheck class names and constructors when you migrate. If you used generic-looking classes such as `Reader` or `Writer`, they may now be specific implementations like `CsvReader`, `JsonReader`, `CsvWriter`, or `JsonLinesWriter`.
- If your code depended on a single installation for everything, verify your imports and `composer.json` against the [Packages](#packages) section and the README for each subpackage.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance63

Regular maintenance activity

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~155 days

Recently: every ~601 days

Total

18

Last Release

960d ago

Major Versions

v0.5.1 → v2.x-dev2023-11-12

PHP version history (2 changes)v0.1PHP &gt;=5.5

v2.x-devPHP &gt;=8

### Community

Maintainers

![](https://www.gravatar.com/avatar/94935088e6eab9c315a8a07d49152d0bd4aaab1fb468d6c481408e10c95babc8?d=identicon)[jotaelesalinas](/maintainers/jotaelesalinas)

---

Top Contributors

[![jotaelesalinas](https://avatars.githubusercontent.com/u/2042875?v=4)](https://github.com/jotaelesalinas "jotaelesalinas (59 commits)")

---

Tags

foreachgeneratorsinput-outputiophpreaderswritersphpioreadwritegeneratorsconsumerinputoutputread-writeproducerrwjotaelesalinasphp-rwgenrwgenjlsalinas

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/jotaelesalinas-php-rwgen/health.svg)

```
[![Health](https://phpackages.com/badges/jotaelesalinas-php-rwgen/health.svg)](https://phpackages.com/packages/jotaelesalinas-php-rwgen)
```

###  Alternatives

[ronanguilloux/php-gpio

GPIO-related utils &amp; toolkit PHP library

2678.0k](/packages/ronanguilloux-php-gpio)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
