salsify/json-streaming-parser
Streaming JSON parser for PHP that processes huge JSON documents without loading them into memory. SAX-style event callbacks via a Listener interface, PSR compliant, installable with Composer. Ideal for large files and low-memory environments.
Adopt When:
Allowed memory exhausted errors).json_decode() is impractical due to size or performance.Look Elsewhere If:
json-schema or spatie/laravel-json-schema-validator).json_decode()).StreamedResponse).For Executives: "This package lets us handle massive JSON files—like 10x larger than before—without crashing servers or slowing down APIs. For example, if we’re importing customer data from a partner system or processing real-time logs, we can avoid costly infrastructure upgrades. It’s a drop-in solution that turns a memory bottleneck into a scalable feature, with minimal dev effort. Think of it as ‘serverless-ready’ JSON parsing for PHP."
For Engineering:
*"The salsify/json-streaming-parser replaces json_decode() for large files by parsing JSON incrementally via callbacks (like SAX for XML). Key benefits:
Listener interface to handle events (e.g., enterObject, scalarValue).Use case: Replace a memory-heavy json_decode(file_get_contents($largeFile)) with:
$parser = new \JsonStreamingParser\Parser(fopen('data.json'), new MyListener());
$parser->parse(); // No memory spikes!
Tradeoff: You lose random access, but gain scalability. Perfect for ETL, APIs, or batch jobs."*
How can I help you explore Laravel packages today?