PHPackages                             zbateson/stream-decorators - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. zbateson/stream-decorators

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

zbateson/stream-decorators
==========================

PHP psr7 stream decorators for mime message part streams

3.0.0(3mo ago)4748.6M—2.1%74BSD-2-ClausePHPPHP &gt;=8.1CI failing

Since May 19Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/zbateson/stream-decorators)[ Packagist](https://packagist.org/packages/zbateson/stream-decorators)[ GitHub Sponsors](https://github.com/zbateson)[ RSS](/packages/zbateson-stream-decorators/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (22)Used By (4)

zbateson/stream-decorators
==========================

[](#zbatesonstream-decorators)

PSR-7 stream decorators for character set conversion and common mail format content encodings.

[![Build Status](https://github.com/zbateson/stream-decorators/actions/workflows/tests.yml/badge.svg)](https://github.com/zbateson/stream-decorators/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/1b4f0722f88a218272b1a0858be60b5399ee41d4290a71f183e250b3a19ad39e/68747470733a2f2f706f7365722e707567782e6f72672f7a62617465736f6e2f73747265616d2d6465636f7261746f72732f646f776e6c6f616473)](//packagist.org/packages/zbateson/stream-decorators)[![Latest Stable Version](https://camo.githubusercontent.com/1ae97702202d73130a0400da0ce789f933f17c188f712e88a58a6ccbd8231dab/68747470733a2f2f706f7365722e707567782e6f72672f7a62617465736f6e2f73747265616d2d6465636f7261746f72732f76)](//packagist.org/packages/zbateson/stream-decorators)

```
composer require zbateson/stream-decorators

```

Sponsors
--------

[](#sponsors)

[![SecuMailer](https://camo.githubusercontent.com/74de27677ddf07fa571fcca6558d34be0fa6486bf473de73261461b89b12e8c5/68747470733a2f2f6d61696c2d6d696d652d7061727365722e6f72672f73706f6e736f72732f6c6f676f2d736563756d61696c65722e706e67)](https://secumailer.com)

A huge thank you to [all my sponsors](https://github.com/sponsors/zbateson). &lt;3

If this project's helped you, please consider [sponsoring me](https://github.com/sponsors/zbateson).

Requirements
------------

[](#requirements)

PHP 8.1 or newer. Tested on PHP 8.1, 8.2, 8.3, 8.4, and 8.5.

Description
-----------

[](#description)

The library provides the following `Psr\Http\Message\StreamInterface` implementations:

- `Base64Stream` - decodes on read and encodes on write to base64
- `CharsetStream` - encodes from `$streamCharset` to `$stringCharset` on read, and vice-versa on write
- `ChunkSplitStream` - splits written characters into lines of `$lineLength` long (stream implementation of PHP's `chunk_split`)
- `DecoratedCachingStream` - a caching stream that writes to a decorated stream, and reads from the cached undecorated stream
- `NonClosingStream` - overrides `close()` and `detach()`, and simply unsets the attached stream without closing it
- `PregReplaceFilterStream` - calls `preg_replace` with passed arguments on every `read()` call
- `QuotedPrintableStream` - decodes on read and encodes on write to quoted-printable
- `SeekingLimitStream` - similar to GuzzleHttp's `LimitStream`, but maintains an internal current read position
- `TellZeroStream` - `tell()` always returns `0` -- used by `DecoratedCachingStream` to wrap a `BufferStream` in a `CachingStream`
- `UUStream` - decodes on read, encodes on write to uu-encoded

Usage
-----

[](#usage)

```
$stream = GuzzleHttp\Psr7\Utils::streamFor($handle);
$b64Stream = new ZBateson\StreamDecorators\Base64Stream($stream);
$charsetStream = new ZBateson\StreamDecorators\CharsetStream($b64Stream, 'UTF-32', 'UTF-8');

while (($line = GuzzleHttp\Psr7\Utils::readLine()) !== false) {
    echo $line, "\r\n";
}
```

Note that `CharsetStream`, depending on the target encoding, may return multiple bytes when a single 'char' is read. If using PHP's `fread`, this will result in a warning. It is recommended to **not** convert to a stream handle (with `StreamWrapper`) when using `CharsetStream`.

License
-------

[](#license)

BSD licensed - please see [license agreement](https://github.com/zbateson/stream-decorators/blob/master/LICENSE).

###  Health Score

67

—

FairBetter than 100% of packages

Maintenance82

Actively maintained with recent releases

Popularity62

Solid adoption and visibility

Community23

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 79.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 ~148 days

Recently: every ~247 days

Total

20

Last Release

94d ago

Major Versions

0.4.1 → 1.0.02018-09-28

1.2.1 → 2.0.02024-03-18

2.1.1 → 3.0.02026-02-13

PHP version history (5 changes)0.1.0PHP &gt;=5.4

1.1.0PHP &gt;=7.1

1.2.0PHP &gt;=7.2

2.0.0PHP &gt;=8.0

3.0.0PHP &gt;=8.1

### Community

Maintainers

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

---

Top Contributors

[![zbateson](https://avatars.githubusercontent.com/u/8356974?v=4)](https://github.com/zbateson "zbateson (119 commits)")[![phpfui](https://avatars.githubusercontent.com/u/7434059?v=4)](https://github.com/phpfui "phpfui (16 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (12 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![svenbw](https://avatars.githubusercontent.com/u/837206?v=4)](https://github.com/svenbw "svenbw (1 commits)")

---

Tags

psr-7stream-decoratorstreamsstreampsr7mailmimecharsetbase64decoratorsquoted-printableuuencode

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/zbateson-stream-decorators/health.svg)

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

###  Alternatives

[zbateson/mail-mime-parser

MIME email message parser

54149.2M79](/packages/zbateson-mail-mime-parser)[php-mime-mail-parser/php-mime-mail-parser

A fully tested email parser for PHP 8.0+ (mailparse extension wrapper).

9979.6M27](/packages/php-mime-mail-parser-php-mime-mail-parser)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M246](/packages/nette-mail)[zbateson/mb-wrapper

Wrapper for mbstring with fallback to iconv for encoding conversion and string manipulation

4948.6M5](/packages/zbateson-mb-wrapper)[goetas/to-swift-mime-parser

Parse a generic mail stream, and convert it to a SwiftMailer Message

1244.4k2](/packages/goetas-to-swift-mime-parser)[bashkarev/email

Faster MIME Mail Parser could be used to parse emails in MIME format.

208.8k](/packages/bashkarev-email)

PHPackages © 2026

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