clue/json-stream
Streaming JSON parser and encoder for PHP that reads and writes large JSON documents incrementally, without loading the whole payload into memory. Built on ReactPHP streams, it handles huge files and endless data feeds efficiently via a simple event-driven API.
{...}{...}{...} with no separator defeat naive explode("\n") parsing. Supporting that format is a scope decision this package makes nearly free.Adopt when most of these hold:
Look elsewhere (or skip) when:
json_decode on the whole body is simpler, faster to ship, and one fewer dependency.explode("\n") + json_decode is zero-dependency and often adequate. This package earns its place when chunk boundaries, concatenation, or malformed-record handling actually bite.halaxa/json-machine) or a validator is a better fit.To executives: A small, free (MIT) library that lets us ingest very large JSON data feeds — customer exports, vendor batch results — without provisioning bigger workers or rewriting our queue pipeline. Adoption cost is one Composer dependency and roughly a day of integration. The main caveat is that the project is quiet (last release 2020, small community), so we'd pin the version, wrap it behind our own interface, and treat it as a vendored utility we can fork if needed — no licensing or lock-in concern.
To engineering: It's a pure incremental JSON parser: push($chunk), get back an array of complete decoded values. It correctly handles tokens split across chunk boundaries and both concatenated and newline-delimited framing, and it has no I/O and no real dependencies. That replaces the buffer-stitching code we'd otherwise write and test ourselves. Constraints to plan around: it parses only — no transport, no validation, no malformed-record recovery — and it's unmaintained since 2020, so keep it behind an internal adapter and treat halaxa/json-machine as the drop-in escape hatch if requirements grow.
How can I help you explore Laravel packages today?