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

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

rodenastyle/stream-parser
=========================

PHP Multiformat Streaming Parser

v2.0.3(1y ago)443195.7k—1.5%48[6 issues](https://github.com/sergiorodenas/stream-parser/issues)[2 PRs](https://github.com/sergiorodenas/stream-parser/pulls)2MITPHPPHP &gt;=7.1|^8.0CI failing

Since May 15Pushed 1y ago12 watchersCompare

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

READMEChangelog (10)Dependencies (4)Versions (23)Used By (2)

⚡ 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 Illuminate\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 Illuminate\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."
  }
}

```

Additionally, you could make use of `->withSeparatedParametersList()` to get the params of each element separated on the `__params` property. Also, `->withoutSkippingFirstElement()` could be of help to parse the very first item (usually the element that contains the elements).

### 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 Illuminate\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 Illuminate\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

57

—

FairBetter than 98% of packages

Maintenance49

Moderate activity, may be stable

Popularity55

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 68.6% 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 ~150 days

Recently: every ~181 days

Total

18

Last Release

370d ago

Major Versions

1.0.5 → 2.0.x-dev2018-07-29

v1.5 → v2.02023-05-20

PHP version history (4 changes)1.0.0PHP ^7.0

v1.2PHP ^7.1.3

v1.5PHP &gt;=7.1

v2.0.2PHP &gt;=7.1|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe659dd274a405d52f9e1970bee7f49f7b29fe71bcf6d49b402d432463b4018b?d=identicon)[Rodenastyle](/maintainers/Rodenastyle)

---

Top Contributors

[![sergiorodenas](https://avatars.githubusercontent.com/u/2689890?v=4)](https://github.com/sergiorodenas "sergiorodenas (48 commits)")[![avido](https://avatars.githubusercontent.com/u/14986?v=4)](https://github.com/avido "avido (5 commits)")[![jn-jairo](https://avatars.githubusercontent.com/u/5104869?v=4)](https://github.com/jn-jairo "jn-jairo (4 commits)")[![webfox-developers](https://avatars.githubusercontent.com/u/12959301?v=4)](https://github.com/webfox-developers "webfox-developers (2 commits)")[![foxbyte-developers](https://avatars.githubusercontent.com/u/12959301?v=4)](https://github.com/foxbyte-developers "foxbyte-developers (2 commits)")[![julianpoma](https://avatars.githubusercontent.com/u/19490445?v=4)](https://github.com/julianpoma "julianpoma (1 commits)")[![lucassouza1](https://avatars.githubusercontent.com/u/195029?v=4)](https://github.com/lucassouza1 "lucassouza1 (1 commits)")[![NetFix1](https://avatars.githubusercontent.com/u/29812836?v=4)](https://github.com/NetFix1 "NetFix1 (1 commits)")[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (1 commits)")[![rw4lll](https://avatars.githubusercontent.com/u/1325502?v=4)](https://github.com/rw4lll "rw4lll (1 commits)")[![jeromegamez](https://avatars.githubusercontent.com/u/67554?v=4)](https://github.com/jeromegamez "jeromegamez (1 commits)")[![SuryaWebfox](https://avatars.githubusercontent.com/u/53416793?v=4)](https://github.com/SuryaWebfox "SuryaWebfox (1 commits)")[![tachigami](https://avatars.githubusercontent.com/u/4858247?v=4)](https://github.com/tachigami "tachigami (1 commits)")[![james-simmonds](https://avatars.githubusercontent.com/u/1891906?v=4)](https://github.com/james-simmonds "james-simmonds (1 commits)")

---

Tags

collectionscsvjsonlaravelparserphpstreamingxmlstreamjsonlaravelxmlparsercsvpullPHP7

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[nilgems/laravel-textract

A Laravel package to extract text from files like DOC, XL, Image, Pdf and more. I've developed this package by inspiring "npm textract".

195.2k](/packages/nilgems-laravel-textract)

PHPackages © 2026

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