PHPackages                             jotaelesalinas/php-data-streams - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. jotaelesalinas/php-data-streams

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

jotaelesalinas/php-data-streams
===============================

Read and write huge CSV, JSON, XML and Excel streams in PHP without running out of memory.

v2.0.0(1mo ago)001MITPHPPHP ^8.1CI failing

Since Aug 20Pushed 1mo ago1 watchersCompare

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

READMEChangelog (10)DependenciesVersions (20)Used By (1)

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

48

—

FairBetter than 94% of packages

Maintenance91

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 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 ~199 days

Recently: every ~795 days

Total

19

Last Release

46d ago

Major Versions

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

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

v2.x-devPHP &gt;=8

v2.0.0PHP ^8.1

### 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-outputiophpreaderswritersjsonxmlstreamingexcelxlsxcsvNDJSONgeneratorstsvlarge filesmemory-efficientdata-streams

### Embed Badge

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

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

###  Alternatives

[faisalman/simple-excel-php

Easily parse / convert / write between Microsoft Excel XML / CSV / TSV / HTML / JSON / etc formats

578610.1k1](/packages/faisalman-simple-excel-php)[rap2hpoutre/fast-excel

Fast Excel import/export for Laravel

2.3k27.0M52](/packages/rap2hpoutre-fast-excel)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.2k70.2M254](/packages/openspout-openspout)[mledoze/countries

List of world countries in JSON, CSV, XML and YAML

6.3k733.8k6](/packages/mledoze-countries)[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3896.2M31](/packages/gotenberg-gotenberg-php)[nuovo/spreadsheet-reader

Spreadsheet reader library for Excel, OpenOffice and structured text files

668891.8k8](/packages/nuovo-spreadsheet-reader)

PHPackages © 2026

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