johnstevenson/json-works
A PHP library for reading, editing, and writing JSON while preserving original formatting and whitespace. It provides a simple API for precise changes to JSON documents, making it ideal for configuration files and other human-maintained JSON that should stay readable.
Architecture fit. json-works is a narrowly scoped utility library, not an architectural component. It solves one problem well: mutating an existing JSON document in place without destroying human-authored formatting (indentation, key order, line endings, trailing newline). That makes it a good fit for a specific class of features — CLI commands and admin tooling that patch composer.json, .eslintrc.json, package.json, IDE config, feature-flag files, or customer-managed JSON blobs — and a poor fit as a general-purpose JSON serializer/deserializer replacement. It has no service provider, no config surface, no framework coupling, so "architecture fit" for a Laravel codebase is really about whether the use case exists. If the product never writes to hand-maintained JSON, this package adds dependency surface for nothing. Its natural home is inside a small adapter class in your application layer, behind an interface such as JsonDocumentEditor, so callers express intent (setKey, removeKey) rather than reaching for RFC 6901 pointer strings directly.
Integration feasibility. Mechanically easy: pure PHP, no extensions, MIT license, standard Composer consumption. There is no Laravel package discovery, so integration is a composer require plus a thin wrapper and a container binding. The real friction is verification, not wiring. Because the library preserves formatting, it necessarily carries its own document parser rather than round-tripping through json_decode/json_encode; that is a second JSON parser in your dependency tree and needs to be treated as such — differential-tested against PHP's native decoder on a corpus of real files, including CRLF, BOM, unicode escapes, deeply nested arrays, duplicate keys, and empty containers.
Technical risk. Runtime risk is low (small surface, no I/O, no network, pure computation). Governance risk is the dominant concern and is what the 26 stars / 0.22 score is signaling: low adoption, a single-maintainer bus factor, and a last release of April 2023, meaning no PHP 8.3/8.4 hardening, no security response path, and no evidence of recent CI. The repository field being reported as unknown compounds this — provenance and release artifacts should be confirmed before adoption. Secondary risks: silent semantic drift if the parser mis-handles an edge case (you get a file that looks right but is invalid); loss of formatting guarantees on constructs the parser doesn't model; and behaviour changes on major-version bumps of a library with no migration documentation.
Key questions.
ext-json/composer-plugin-api constraints does the current release declare, and does that intersect Laravel 10/11 (PHP 8.1–8.3)?JsonManipulator for composer files, seld/jsonlint for validation), and can we swap without changing call sites?Stack fit. Consume directly via Composer and wrap it. Do not expose JsonWorks\* types in application or domain signatures; expose a small internal interface with methods that mirror the product's needs. This decouples the codebase from an unmaintained dependency and makes a future fork or replacement a one-file change. Keep the wrapper in a single namespace (e.g. App\Support\Json) and forbid direct use elsewhere via a lint/architecture rule if you have one.
Migration path. Typically this replaces one of three things: regex/string surgery on JSON files, full json_decode → mutate → json_encode round-trips that reformat user files, or bespoke line-based editing. Each has a distinct migration: regex replacement is a straightforward improvement; the decode/encode path is the most common case and is where the format-preservation value is realised; bespoke editors should be retired file-by-file, not wholesale. If composer.json is the primary target, evaluate whether Composer's own JsonManipulator already covers it before adding a dependency.
Compatibility. Pin an exact version in composer.json and commit the lock file. Verify declared PHP constraints against the Laravel versions in support. Watch for conflicts in Composer-plugin contexts — the author is active in the Composer ecosystem, and Composer itself ships JSON-manipulation code, so class or version collisions are plausible if this is used inside a plugin. Add a contract test suite (golden-file fixtures: input JSON, pointer operation, expected byte-exact output) that runs against the pinned version, so an upgrade that silently changes formatting fails the build rather than corrupting a customer file.
Sequencing.
json_decode sanity check) before persisting.Maintenance. Expect to own this dependency. Budget for: periodic manual review of the pinned version, an internal fork if a PHP compatibility break lands, and a documented exit path to JsonManipulator or a hand-rolled formatter should that be needed. Treat it as "vendored with intent," not "install and forget." The single-maintainer, stale-release profile means no upstream security patching — acceptable for a computation-only library with no I/O, provided the wrapper is the only integration point.
Support. Community-only, no SLA, no vendor to escalate to. Internal support burden is low if the wrapper's API is small and the golden-file tests exist; it becomes high if developers call the library directly and start filing bugs against pointer semantics. Document the wrapper as the supported surface and note that RFC 6901 pointer syntax is an implementation detail.
Scaling. Bounded by file size and memory, not request volume. It parses whole documents in memory, so it is appropriate for config-scale files (kilobytes to low megabytes) and inappropriate for multi-megabyte or streamed JSON. Concurrency is the real scaling concern: two processes editing the same file will lose updates, so writes must be serialised (lock file) or made atomic (write temp, rename). Cache nothing — always re-read from disk before applying a pointer operation.
Failure modes.
json_decode before persisting and by the fixture suite.Ramp-up. Low. The API is small, the documentation is adequate for the core operations, and the only prerequisite knowledge is JSON Pointer syntax (RFC 6901), which most engineers pick up in under an hour. The wrapper should hide pointers behind named operations for the common cases and expose an escape hatch for advanced ones. Realistic estimate: half a day for a mid-level engineer to ship the adapter and fixtures, plus one review cycle to agree on the atomic-write and validation gates. The learning cost is not the library — it is remembering that format preservation is a correctness requirement to be tested, not an assumed property.
How can I help you explore Laravel packages today?