cerbero/lazy-json
Lazy JSON is a lightweight PHP package for memory-efficient parsing of large JSON documents. Instead of decoding an entire payload at once, it lets you traverse JSON lazily, reducing memory usage and making big files or streams easier to process.
json_decode() within PHP's memory_limit — partner data feeds, nightly vendor exports, bulk import/export tools, webhook or event payload processing, analytics snapshots — becomes feasible without inventing an internal streaming parser or standing up a queue-plus-chunking pipeline.LazyCollection, the same map/filter/chunk/take vocabulary the team already uses applies to streams. That means ingestion work can be scheduled alongside normal Eloquent/collection work rather than as a separate "streaming infrastructure" initiative. It also defers investments in temp tables, staging databases, or dedicated ETL services.laravel-data, JSON Schema) rather than being expected from this dependency.Adopt when:
LazyCollection semantics (map, filter, chunk, each) with early termination and constant memory.Look elsewhere when:
json_decode() is faster, simpler, zero-dependency, and well understood.laravel-data/spatie/laravel-data or a JSON Schema validator rather than relying on this package for correctness.league/csv, large XML needs XMLReader/streaming parsers.halaxa/json-machine directly and against native/extension-based options; a thin wrapper can add overhead.illuminate/collections dependency — the "framework-agnostic" claim deserves verification against your runtime.To executives: We can unlock several data-heavy features — large vendor feeds, bulk import/export, upload inspection — without new infrastructure or a custom parser. The candidate is a small, MIT-licensed, single-purpose PHP library that streams JSON instead of loading it whole, which removes a class of out-of-memory failures and worker timeouts that would otherwise surface as production incidents and support load. Cost is near zero; the main risk is that it is a low-adoption, single-maintainer project, so we would isolate it behind our own interface and keep an exit path. Recommend a short, time-boxed spike against one real feed before committing.
To engineering: This is the parsing/traversal layer only — it gives us depth-agnostic, source-agnostic JSON iteration expressed as LazyCollection, so memory stays flat and take/early-exit actually short-circuit. It does not do validation, DTO mapping, or schema enforcement; those stay with our existing tooling. Two caveats to size: (1) benchmark it against json-machine on our real payloads before adopting, since it is a wrapper, and (2) assume we own the maintenance — pin the version, wrap it in an adapter, and add a contract test so we can replace it in an afternoon if upstream goes quiet.
How can I help you explore Laravel packages today?