PHPackages                             notioncommotion/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. notioncommotion/stream-parser

ActiveProject[Parsing &amp; Serialization](/categories/parsing)

notioncommotion/stream-parser
=============================

Wrapper for socket stream. Adds deliminator and serializing.

v1.0.2(6y ago)024PHPPHP &gt;=7.2

Since Jun 29Pushed 6y agoCompare

[ Source](https://github.com/NotionCommotion/SteamParser)[ Packagist](https://packagist.org/packages/notioncommotion/stream-parser)[ RSS](/packages/notioncommotion-stream-parser/feed)WikiDiscussions master Synced 3d ago

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

StreamParser
============

[](#streamparser)

Wrapper for ReactPHP socket stream. Allows encoding using length prefix or character deliminator (not tested), or none (for testing only). Allows serializing using JSON or CBOR and if clientn communicates first will use that serializer.

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

[](#installation)

Add notioncommotion/stream-parser as a requirement to composer.json:

```
{
    "require": {
       "notioncommotion/stream-parser": "^1.0"
    }
}
```

```
composer update

```

Usage
-----

[](#usage)

### Server usage.

[](#server-usage)

See the [server example](examples/server.php).

Values for the pem keys, and possibly others in [config.client.ini](examples/config.client.ini) will need to be update to reflect your requirements. Be sure that log file locations are writable.

Current available values for encoder are lengthprefix (tested), lengthprefix (not tested), and no (i.e. none which is only used for testing only). Current available values for serializer are JSON and [CBOR](https://cbor.io/).

```
ip                      =   0.0.0.0     ;Server listens on
port_tcp                =   1338        ;Leave blank to not use.
port_tls                =   1339        ;Leave blank to not use.
passphrase              =   ;optional key passphrase.  Uncomment if you use.
local_pk                =   /etc/pki/tls/private/sample-private-key.pem
local_cert              =   /etc/pki/tls/certs/sample-public-certificate.pem
local_pk_cert           =   /etc/pki/tls/private/sample-private-key-with-public-certificate.pem ;Both private key and public certificate
logMessages             =   0 ;If -1, do not log LengthPrefixStream, if value, log and crop, if zero, log and don't crop
summaryStreamLog        =   log/summary_stream.log ;If set, will write all read and write traphic to this file
rawReadStreamLog        =   log/raw_read_stream.log ;If set, will write all raw hex read traphic to this file
rawWriteStreamLog       =   log/raw_write_stream.log ;If set, will write all raw hex read traphic to this file
maxMessageLength        =   1000000     ;override for testing only.
encoder                 =   lengthprefix    ;lengthprefix/newline/no
serializers[]           =   cbor
serializers[]           =   json

```

```
$stream=new NotionCommotion\StreamParser\ServerStreamParser(
    React\Stream\DuplexStreamInterface $stream,
    NotionCommotion\StreamParser\Encoders\EncoderInterface $encoder,
    [NotionCommotion\StreamParser\Serializer\SerializerInterface $serializer],
    array $settings
);
```

To start the example server, using the following from the command line:

`php server.php`

### Client usage.

[](#client-usage)

See the [client example](examples/client.php).

Values for url, peer\_name, the pem keys, and possibly others in [config.client.ini](examples/config.client.ini) will need to be update to reflect your requirements. Be sure that log file locations are writable.

Current available values for encoder are lengthprefix (tested), lengthprefix (not tested), and no (i.e. none which is only used for testing only). Current available values for serializer are JSON and [CBOR](https://cbor.io/).

```
url                     =   11.22.33.44
port                    =   1339            ;1338 is for TLS and 1339 is for TLS
peer_name               =   example.com
passphrase              =   ;optional key passphrase.  Uncomment if you use.
local_cert              =   /etc/pki/tls/certs/sample-public-certificate.pem    ;or ca
logMessages             =   0 ;If -1, do not log LengthPrefixStream, if value, log and crop, if zero, log and don't crop
summaryStreamLog        =   log/summary_stream.log ;If set, will write all read and write traphic to this file
rawReadStreamLog        =   log/raw_read_stream.log ;If set, will write all raw hex read traphic to this file
rawWriteStreamLog       =   log/raw_write_stream.log ;If set, will write all raw hex read traphic to this file
maxMessageLength        =   1000000 ;override for testing only
encoder                 =   lengthprefix   ;lengthprefix/newline/no
serializer              =   cbor   ;cbor/json

```

```
$stream=new NotionCommotion\StreamParser\StreamParser(
    React\Stream\DuplexStreamInterface $stream,
    NotionCommotion\StreamParser\Encoders\EncoderInterface $encoder,
    NotionCommotion\StreamParser\Serializer\SerializerInterface $serializer,
    array $settings
);
```

Be sure server is started first, and then start example client using the following from the command line:

`php client.php`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

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

Total

3

Last Release

2425d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5069750197c1041a9861733b8125c3c6adf154f05e35b1c8dc2a9608cc1722e2?d=identicon)[NotionCommotion](/maintainers/NotionCommotion)

---

Top Contributors

[![NotionCommotion](https://avatars.githubusercontent.com/u/2005437?v=4)](https://github.com/NotionCommotion "NotionCommotion (8 commits)")

### Embed Badge

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

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

###  Alternatives

[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k234.7M20.6k](/packages/friendsofphp-php-cs-fixer)[react/react

ReactPHP: Event-driven, non-blocking I/O with PHP.

9.1k3.6M63](/packages/react-react)[php-pm/php-pm

PHP-PM is a process manager, supercharger and load balancer for PHP applications.

6.6k441.3k8](/packages/php-pm-php-pm)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)[clue/ndjson-react

Streaming newline-delimited JSON (NDJSON) parser and encoder for ReactPHP.

15267.7M16](/packages/clue-ndjson-react)[clue/docker-react

Async, event-driven access to the Docker Engine API, built on top of ReactPHP.

113154.9k1](/packages/clue-docker-react)

PHPackages © 2026

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