PHPackages                             austinhyde/paperboat - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. austinhyde/paperboat

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

austinhyde/paperboat
====================

A streaming JSON emitter

v0.1.0(11y ago)321MITPHPPHP &gt;=5.4.0

Since May 4Pushed 11y ago1 watchersCompare

[ Source](https://github.com/austinhyde/paperboat)[ Packagist](https://packagist.org/packages/austinhyde/paperboat)[ Docs](https://github.com/austinhyde/paperboat)[ RSS](/packages/austinhyde-paperboat/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

PaperBoat - Streaming JSON Output
=================================

[](#paperboat---streaming-json-output)

[![Build Status](https://camo.githubusercontent.com/f23ba05363ae0e93a8c4878cad967b85f48c448256147671e27c511e859bbbf4/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f61757374696e687964652f7061706572626f61742f6d61737465722e7376673f7374796c653d666c6174)](https://travis-ci.org/austinhyde/paperboat)[![Latest Version](https://camo.githubusercontent.com/8d34ef9b417030e495098f737fdef84142b2fef6461aeeaa97965b13f7649bea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f61757374696e687964652f7061706572626f61742e7376673f7374796c653d666c6174)](https://github.com/austinhyde/paperboat/releases)[![MIT Licensed](https://camo.githubusercontent.com/f48f8d6cf609f5b181b9c3218a85175fe8a5809c7ea400347f39697a5d55065d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c6174)](https://github.com/austinhyde/paperboat/blob/master/LICENSE.md)

This is an extremely simple, and **very alpha quality** implementation of a Streaming JSON outputter.

Show me the goods
=================

[](#show-me-the-goods)

```
$stream = new PaperBoat\JsonStream();
$stream
  ->startObject()
  ->property('data')
  ->startArray();

$i = 0;
while ($row = $pdoStmt->fetch(PDO::FETCH_ASSOC)) {
  $i++;
  $stream->value($row);
}

$stream
  ->stopArray()
  ->property('meta')
  ->startObject()
    ->property('count', $i)
  ->stopObject()
  ->stopObject();
```

This outputs, for example,

```
{"data":[{"id":1,"name":"Bill Murray"},{"id":2,"name":"Tom Hanks"},{"id":3,"name":"Sigourney Weaver"}],"meta":{"count":3}}
```

Usage
=====

[](#usage)

The primary class you interact with is `PaperBoat\JsonStream`. The constructor takes an optional `PaperBoat\OutputStream` parameter, which tells it where to output JSON to. By default, this is a `PaperBoat\OutputStream\StdoutStream`, which just prints to STDOUT or the HTTP response.

The following methods construct JSON output:

- `startArray()` - Begins outputting an array.
- `stopArray()` - Closes an array.
- `startObject()` - Begins outputting an object.
- `stopObject()` - Closes an object.
- `property($name[, $data])` - Adds a property to an object. If you do not provide the value here, you must call `startArray()`, `startObject()`, or `value()` next.
- `value($data)` - Adds data to the stream, by JSON encoding it.

The following methods control how data is output:

- `setAutomaticFlushing($value)` - Controls whether the `OutputStream` is flushed automatically after data is written to the stream. Defaults to true. If you set this false, you are responsible for calling `->flush()` when appropriate.
- `setJsonFlags($value)` - Sets the flags passed to [`json_encode()`](http://us1.php.net/manual/en/function.json-encode.php)
- `flush()` - Simply calls the provided `OutputStream`'s `flush()` method.

Installation
============

[](#installation)

Via Composer.

```
$ composer require austinhyde/paperboat
```

Contributing
============

[](#contributing)

See [CONTRIBUTING](https://github.com/austinhyde/paperboat/blob/master/CONTRIBUTING.md)

FAQ
===

[](#faq)

##### Why PaperBoat?

[](#why-paperboat)

Streams of lightweight data =&gt; paper boats floating down a stream of water

##### Why do I need this?

[](#why-do-i-need-this)

You would use this if you need to output a large amount of JSON data without holding the whole data structure in memory at once.

Most people probably don't need this.

##### Why did you make this?

[](#why-did-you-make-this)

1. I was bored
2. It didn't exist yet
3. Someone might need it, someday

##### Are these really frequently asked questions?

[](#are-these-really-frequently-asked-questions)

No, this is a sham, just like all the other FAQs on GitHub.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

4033d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2c221166d547b835ed6aa280ffc6a4397686c787257bc01652a474202ccc7c9c?d=identicon)[austinhyde](/maintainers/austinhyde)

---

Top Contributors

[![austinhyde](https://avatars.githubusercontent.com/u/694995?v=4)](https://github.com/austinhyde "austinhyde (12 commits)")

---

Tags

jsonphpstream

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/austinhyde-paperboat/health.svg)

```
[![Health](https://phpackages.com/badges/austinhyde-paperboat/health.svg)](https://phpackages.com/packages/austinhyde-paperboat)
```

PHPackages © 2026

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