PHPackages                             progerwtf/stream-parser - 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. progerwtf/stream-parser

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

progerwtf/stream-parser
=======================

PHP Multiformat Streaming Parser

v1.2(7y ago)05MITPHPPHP ^7.1.3

Since May 15Pushed 6y agoCompare

[ Source](https://github.com/progerwtf/stream-parser)[ Packagist](https://packagist.org/packages/progerwtf/stream-parser)[ Patreon](https://www.patreon.com/rodenas)[ RSS](/packages/progerwtf-stream-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (10)Used By (0)

⚡ PHP7 / Laravel Multi-format Streaming Parser
==============================================

[](#-php7--laravel-multi-format-streaming-parser)

[![Build Status](https://camo.githubusercontent.com/f58ca9308d0eecf5b393906052f92195ad47a956e03697c520af47b4b156a839/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f526f64656e617374796c652f73747265616d2d7061727365722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Rodenastyle/stream-parser/build-status/master)[![Latest Version on Packagist](https://camo.githubusercontent.com/5f711ea408e3d37d52b883dec9dfbe1eab54e96b0a53fc20480656bd7105fb0a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f64656e617374796c652f73747265616d2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rodenastyle/stream-parser)[![Quality Score](https://camo.githubusercontent.com/234f2f87b2c591f1a5133390a02f61af1a58ff23ad55c4305fedd99c9dc08204/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f726f64656e617374796c652f73747265616d2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Rodenastyle/stream-parser/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/650b731075bead16cd4a626d853dd6fed19fc18bfae1a0c5274754a03d2eef1b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f526f64656e617374796c652f73747265616d2d7061727365722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Rodenastyle/stream-parser/?branch=master)[![License](https://camo.githubusercontent.com/d423a456ff854e0e94855ac25d348d9ec2d603eb322bfc660aa21cba0eabeeef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f526f64656e617374796c652f73747265616d2d7061727365722e737667)](https://packagist.org/packages/Rodenastyle/stream-parser)

> When it comes to parsing XML/CSV/JSON/... documents, there are 2 approaches to consider:
>
> **DOM loading**: loads all the document, making it easy to navigate and parse, and as such provides maximum flexibility for developers.
>
> **Streaming**: implies iterating through the document, acts like a cursor and stops at each element in its way, thus avoiding memory overkill.
>
> [https://www.linkedin.com/pulse/processing-xml-documents-dom-vs-streaming-marius-ilina/](https://www.linkedin.com/pulse/processing-xml-documents-dom-vs-streaming-marius-ilina)

Thus, when it comes to big files, callbacks will be executed meanwhile file is downloading and will be much more efficient as far as memory is concerned.

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

[](#installation)

```
composer require rodenastyle/stream-parser

```

Recommended usage
-----------------

[](#recommended-usage)

Delegate as possible the callback execution so it doesn't blocks the document reading:

(Laravel Queue based example)

```
use Tightenco\Collect\Support\Collection;

StreamParser::xml("https://example.com/users.xml")->each(function(Collection $user){
    dispatch(new App\Jobs\SendEmail($user));
});
```

Practical Input/Code/Output demos
---------------------------------

[](#practical-inputcodeoutput-demos)

### XML

[](#xml)

```

        The Iliad and The Odyssey
        12.95

                Best translation I've read.

                I like other versions better.

    [...]

```

```
use Tightenco\Collect\Support\Collection;

StreamParser::xml("https://example.com/books.xml")->each(function(Collection $book){
    var_dump($book);
    var_dump($book->get('comments')->toArray());
});
```

```
class Tightenco\Collect\Support\Collection#19 (1) {
  protected $items =>
  array(4) {
    'ISBN' =>
    string(13) "10-000000-001"
    'title' =>
    string(25) "The Iliad and The Odyssey"
    'price' =>
    string(5) "12.95"
    'comments' =>
    class Tightenco\Collect\Support\Collection#17 (1) {
      protected $items =>
      array(2) {
        ...
      }
    }
  }
}
array(2) {
  [0] =>
  array(2) {
    'rating' =>
    string(1) "4"
    'userComment' =>
    string(27) "Best translation I've read."
  }
  [1] =>
  array(2) {
    'rating' =>
    string(1) "2"
    'userComment' =>
    string(29) "I like other versions better."
  }
}

```

### JSON

[](#json)

```
[
  {
    "title": "The Iliad and The Odyssey",
    "price": 12.95,
    "comments": [
      {"comment": "Best translation I've read."},
      {"comment": "I like other versions better."}
    ]
  },
  {
    "title": "Anthology of World Literature",
    "price": 24.95,
    "comments": [
      {"comment": "Needs more modern literature."},
      {"comment": "Excellent overview of world literature."}
    ]
  }
]
```

```
use Tightenco\Collect\Support\Collection;

StreamParser::json("https://example.com/books.json")->each(function(Collection $book){
    var_dump($book->get('comments')->count());
});
```

```
int(2)
int(2)

```

### CSV

[](#csv)

```
title,price,comments
The Iliad and The Odyssey,12.95,"Best translation I've read.,I like other versions better."
Anthology of World Literature,24.95,"Needs more modern literature.,Excellent overview of world literature."
```

```
use Tightenco\Collect\Support\Collection;

StreamParser::csv("https://example.com/books.csv")->each(function(Collection $book){
    var_dump($book->get('comments')->last());
});
```

```
string(29) "I like other versions better."
string(39) "Excellent overview of world literature."

```

License
-------

[](#license)

This library is released under [MIT](http://www.tldrlegal.com/license/mit-license) license.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 76.3% 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 ~86 days

Recently: every ~156 days

Total

9

Last Release

2232d ago

Major Versions

v1.2 → 2.0.x-dev2020-04-05

PHP version history (2 changes)1.0.0PHP ^7.0

v1.2PHP ^7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ebd3964ccd26e4c6e42074a48114a1f8081153c8d91bcbae53c0af6a93b9f77?d=identicon)[progerwtf](/maintainers/progerwtf)

---

Top Contributors

[![sergiorodenas](https://avatars.githubusercontent.com/u/2689890?v=4)](https://github.com/sergiorodenas "sergiorodenas (29 commits)")[![jn-jairo](https://avatars.githubusercontent.com/u/5104869?v=4)](https://github.com/jn-jairo "jn-jairo (4 commits)")[![james-simmonds](https://avatars.githubusercontent.com/u/1891906?v=4)](https://github.com/james-simmonds "james-simmonds (1 commits)")[![progerwtf](https://avatars.githubusercontent.com/u/40971052?v=4)](https://github.com/progerwtf "progerwtf (1 commits)")[![tachigami](https://avatars.githubusercontent.com/u/4858247?v=4)](https://github.com/tachigami "tachigami (1 commits)")[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (1 commits)")[![jeromegamez](https://avatars.githubusercontent.com/u/67554?v=4)](https://github.com/jeromegamez "jeromegamez (1 commits)")

---

Tags

streamjsonlaravelxmlparsercsvpullPHP7

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/progerwtf-stream-parser/health.svg)

```
[![Health](https://phpackages.com/badges/progerwtf-stream-parser/health.svg)](https://phpackages.com/packages/progerwtf-stream-parser)
```

###  Alternatives

[rodenastyle/stream-parser

PHP Multiformat Streaming Parser

443195.7k2](/packages/rodenastyle-stream-parser)[mledoze/countries

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

6.2k699.7k6](/packages/mledoze-countries)[faisalman/simple-excel-php

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

582599.4k1](/packages/faisalman-simple-excel-php)[ee/dataexporter-bundle

Easy export data to CSV, XML, HTML, JSON or XLS

4982.5k](/packages/ee-dataexporter-bundle)[dracoblue/craur

A lossless xml to json and json to xml converter (and csv/xlsx/yaml). Writing PHP Json/Xml/Csv/Yaml/excel Importers made easy

4643.1k2](/packages/dracoblue-craur)[initred/laravel-tabula

laravel-tabula is a tool for liberating data tables trapped inside PDF files for the Laravel framework.

1418.6k](/packages/initred-laravel-tabula)

PHPackages © 2026

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