keboola/json-parser
A PHP library from Keboola for parsing JSON into PHP data structures, with configurable options for handling JSON strings and files. Lightweight and straightforward to integrate into existing PHP projects.
data.csv, data_items.csv, …). That directly supports decisions like "should the export be one wide spreadsheet or a zip of related tables?" — and it lets you ship the multi-table option cheaply to learn whether customers actually want it.COPY/upload into Snowflake, BigQuery, or Redshift. Relevant if the roadmap includes a lightweight sync pipeline rather than a full ELT vendor.json_decode() with JSON_THROW_ON_ERROR covers that in one line. If better parse errors are your only need, do not add a dependency — that framing undersells what the library is actually for.Consider it when:
league/csv plus hand-rolled flattening is exactly this opinionated structure — if you don't want it, the build-vs-buy case collapses.JsonToCsvExporter interface in your Laravel app that the rest of the codebase depends on, with the package as one swappable adapter. There is no service provider, facade, or config file, so this wrapping is not optional hygiene — it's how you keep the dependency from leaking into controllers and models.Look elsewhere (or build) when:
collect($json)->map(...) plus fputcsv/league/csv handles a surprising amount of real-world data in ~30 lines you fully control. The marginal value of the dependency is small; the marginal cost is nonzero.PhpSpreadsheet or a hosted export service.Risk note for the adoption decision: low stars and zero dependents are not disqualifying for a small utility, but they do mean you own the maintenance. It pulls Keboola's own php-temp/php-utils transitively — those are the pieces most likely to conflict with your PHP version or filesystem assumptions, so pin them in composer.lock and treat upgrades as manual review. Also budget for CSV formula injection (cells starting with =, +, -, @) if humans will open these exports in Excel. Decide up front whether you'd fork it if upstream goes quiet; if the answer is no, don't ship it in anything load-bearing.
For executives: This is a small, free, MIT-licensed utility that turns nested JSON into one or more CSV files — the tedious flattening step behind any data-export feature. It lets us ship an export capability in days rather than weeks, at zero licensing cost and with no vendor contract. It is deliberately not a strategic dependency: it's a narrow helper we will wrap behind our own interface, so replacing it later is an afternoon of work, not a migration project. The trade-off is honest: it's a six-star, single-maintainer project with no commercial support, so we should treat it as tactical and keep it off the critical path for anything contractual. Recommendation: adopt for the export feature, cap the investment, and revisit if export volume or customer commitments grow.
For engineering: Scope is a single responsibility — take a JSON document, return a set of related CSV files (root scalars as one table, each nested array as a child table with a parent-link column), with inferred column types. There's no service provider or config, so plan for ~a day of wiring: bind a singleton with a PSR-3 logger, add a config file (temp path, delimiter, enclosure), and translate the returned file objects into Storage puts — it writes real files to a temp directory, so keep it inside ShouldQueue jobs and console commands, never in the request path, and do atomic write-then-move with cleanup in a finally or terminating hook. Define App\Contracts\JsonToCsvExporter and implement it with the package as one adapter; never call the parser classes from controllers or models. Before it touches anything customer-visible: run it against three representative production payloads and capture exact CSV output as golden fixtures, agree the header-naming and child-table contract with downstream consumers, sanitize formula-injection prefixes, verify the pinned release's PHP/Laravel constraint (8.1+/Laravel 10–11) and that the transitive Keboola temp/utils packages behave in our containers, and add row-count/file-size/duration logging. If league/csv plus a hand-rolled flattener turns out comparable in effort once you've done that spike, prefer the in-house version and drop the dependency — but if the spike shows the package's tree-to-tables behavior is 80% of what we need, keep it and spend the saved days on the export UX instead.
How can I help you explore Laravel packages today?