{"id":35125667,"url":"https://github.com/austinhyde/paperboat","last_synced_at":"2026-04-25T06:36:09.977Z","repository":{"id":31447459,"uuid":"35011237","full_name":"austinhyde/paperboat","owner":"austinhyde","description":"PaperBoat - A Streaming JSON Output Library","archived":false,"fork":false,"pushed_at":"2015-05-16T22:46:47.000Z","size":148,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-04-25T06:36:05.393Z","etag":null,"topics":["json","php","stream"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/austinhyde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-04T03:05:37.000Z","updated_at":"2015-05-08T18:03:36.000Z","dependencies_parsed_at":"2022-08-30T00:11:40.753Z","dependency_job_id":null,"html_url":"https://github.com/austinhyde/paperboat","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/austinhyde/paperboat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinhyde%2Fpaperboat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinhyde%2Fpaperboat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinhyde%2Fpaperboat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinhyde%2Fpaperboat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/austinhyde","download_url":"https://codeload.github.com/austinhyde/paperboat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austinhyde%2Fpaperboat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32253251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T04:23:17.126Z","status":"ssl_error","status_checked_at":"2026-04-25T04:21:53.360Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","php","stream"],"created_at":"2025-12-28T02:35:49.650Z","updated_at":"2026-04-25T06:36:09.747Z","avatar_url":"https://github.com/austinhyde.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PaperBoat - Streaming JSON Output\n\n[![Build Status](https://img.shields.io/travis/austinhyde/paperboat/master.svg?style=flat)](https://travis-ci.org/austinhyde/paperboat)\n[![Latest Version](https://img.shields.io/github/release/austinhyde/paperboat.svg?style=flat)](https://github.com/austinhyde/paperboat/releases)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/austinhyde/paperboat/blob/master/LICENSE.md)\n\nThis is an extremely simple, and **very alpha quality** implementation of a Streaming JSON outputter.\n\n# Show me the goods\n\n```php\n$stream = new PaperBoat\\JsonStream();\n$stream\n  -\u003estartObject()\n  -\u003eproperty('data')\n  -\u003estartArray();\n\n$i = 0;\nwhile ($row = $pdoStmt-\u003efetch(PDO::FETCH_ASSOC)) {\n  $i++;\n  $stream-\u003evalue($row);\n}\n\n$stream\n  -\u003estopArray()\n  -\u003eproperty('meta')\n  -\u003estartObject()\n    -\u003eproperty('count', $i)\n  -\u003estopObject()\n  -\u003estopObject();  \n```\n\nThis outputs, for example,\n\n```json\n{\"data\":[{\"id\":1,\"name\":\"Bill Murray\"},{\"id\":2,\"name\":\"Tom Hanks\"},{\"id\":3,\"name\":\"Sigourney Weaver\"}],\"meta\":{\"count\":3}}\n```\n\n# Usage\n\nThe 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.\n\nThe following methods construct JSON output:\n\n* `startArray()` - Begins outputting an array.\n* `stopArray()` - Closes an array.\n* `startObject()` - Begins outputting an object.\n* `stopObject()` - Closes an object.\n* `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.\n* `value($data)` - Adds data to the stream, by JSON encoding it.\n\nThe following methods control how data is output:\n\n* `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 `-\u003eflush()` when appropriate.\n* `setJsonFlags($value)` - Sets the flags passed to [`json_encode()`](http://us1.php.net/manual/en/function.json-encode.php)\n* `flush()` - Simply calls the provided `OutputStream`'s `flush()` method.\n\n# Installation\n\nVia Composer.\n\n```bash\n$ composer require austinhyde/paperboat\n```\n\n# Contributing\n\nSee [CONTRIBUTING](https://github.com/austinhyde/paperboat/blob/master/CONTRIBUTING.md)\n\n# FAQ\n\n##### Why PaperBoat?\n\nStreams of lightweight data =\u003e paper boats floating down a stream of water\n\n##### Why do I need this?\n\nYou would use this if you need to output a large amount of JSON data without holding the whole data structure in memory at once.\n\nMost people probably don't need this.\n\n##### Why did you make this?\n\n1. I was bored\n2. It didn't exist yet\n3. Someone might need it, someday\n\n##### Are these really frequently asked questions?\n\nNo, this is a sham, just like all the other FAQs on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinhyde%2Fpaperboat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustinhyde%2Fpaperboat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustinhyde%2Fpaperboat/lists"}