PHPackages                             bhattaganesh/json-stream-writer - 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. bhattaganesh/json-stream-writer

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

bhattaganesh/json-stream-writer
===============================

A scalable PHP library for writing large datasets into JSON streams.

1.0.0(1y ago)06MITPHPPHP &gt;=7.4

Since Sep 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bhattaganesh/json-stream-writer)[ Packagist](https://packagist.org/packages/bhattaganesh/json-stream-writer)[ RSS](/packages/bhattaganesh-json-stream-writer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

JSON Stream Writer
==================

[](#json-stream-writer)

A PHP library to efficiently write large JSON datasets to a file. This is useful when dealing with large amounts of data and you need to export it to JSON without consuming too much memory.

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

[](#installation)

Via Composer:

```
composer require bhattaganesh/json-stream-writer
```

Usage
-----

[](#usage)

```
require_once __DIR__ . '/../vendor/autoload.php';

use JsonStreamWriter\Writer\JsonStreamWriter;

try {
    $streamWriter = new JsonStreamWriter(__DIR__ . '/output.json', true); // Use false to disable pretty-printing

    // Set metadata for the JSON file
    $streamWriter->setValue('manifest', array(
        'version' => '1.0',
        'created_at' => date('Y-m-d H:i:s')
    ));

    // Create a new section called "users"
    $streamWriter->createSection('users');

    // Append items to the "users" section
    $streamWriter->appendItems(array_fill(0, 3000, [
        'id' => rand(1, 10000), // Random ID between 1 and 10000
        'name' => 'User ' . rand(1, 10000), // Random name
        'email' => 'user' . rand(1, 10000) . '@example.com', // Random email
    ]));

    // Create another section called "products"
    $streamWriter->createSection('products');

    // Append items to the "products" section
    $streamWriter->appendItems([
        ['id' => 101, 'name' => 'Laptop', 'price' => 999.99],
        ['id' => 102, 'name' => 'Mouse', 'price' => 19.99],
    ]);

    // Finalize the JSON file
    $streamWriter->finalize();

    echo "JSON stream writing completed successfully.\n";
} catch (\Exception $e) {
    echo "An error occurred: " . $e->getMessage() . "\n";
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

610d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a9fe4cb3d2621efe7ede970472cada71ab9daefa308a336d40fd2c6cf240224?d=identicon)[bhattaganesh](/maintainers/bhattaganesh)

---

Top Contributors

[![bhattaganesh](https://avatars.githubusercontent.com/u/49543894?v=4)](https://github.com/bhattaganesh "bhattaganesh (6 commits)")

---

Tags

streamjsonwriterlarge-dataset

### Embed Badge

![Health badge](/badges/bhattaganesh-json-stream-writer/health.svg)

```
[![Health](https://phpackages.com/badges/bhattaganesh-json-stream-writer/health.svg)](https://phpackages.com/packages/bhattaganesh-json-stream-writer)
```

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k316.9M613](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30422.2M45](/packages/colinodell-json5)[clue/ndjson-react

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

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

PHPackages © 2026

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