webmozart/json
A robust PHP library for decoding, encoding, and validating JSON. It provides clear error messages with line and column details, JSON Schema validation, and convenient file handling via JsonFile, making JSON processing safer and easier in PHP applications.
json_decode() checks or Laravel's Validator.Consider only if:
webmozart/json is already a transitive or direct dependency, and rewriting is out of scope for the current cycle.JsonException reporting the failing JSON pointer), and you're willing to freeze the dependency.$ref resolution across remote schemas, or format assertions.Look elsewhere if — which is the default for any new work:
opis/json-schema (actively maintained, draft 2020-12) or justinrainbow/json-schema (widely used, still maintained).Illuminate\Validation, spatie/laravel-data, or Form Requests integrate with the framework's error handling and localization out of the box.swaggest/php-json-schema or opis before committing.Verdict: Treat as legacy-compatible only, not adoptable for new features. Recommend a migration path rather than a greenfield dependency.
To executives:
We evaluated a JSON validation library that would let us enforce strict, schema-defined contracts on data entering our platform — a building block for partner integrations and config-driven features. It's a mature design with a permissive MIT license, but it hasn't been updated since 2016 and has no active maintainer. Recommendation: do not adopt for new work. If it already exists in our stack, budget a low-effort migration to a maintained replacement during the next platform upgrade. This is a risk-reduction decision, not a capability gap — equivalent, actively maintained options exist at no license cost.
To engineering:
webmozart/jsongives you aJsonDecoder/JsonEncoderpair with JSON Schema validation and precise pointer-based error paths — genuinely pleasant ergonomics for its era. The blocker is maintenance: last release Jan 2016, no PHP 8 verification, no upstream repo activity, no security response. If it's already incomposer.lock(often via older Symfony packages), pin it and add acomposer auditgate; if you're choosing fresh, useopis/json-schemafor schema validation or Laravel's nativeValidator+spatie/laravel-datafor DTO-shaped payloads. Migration is typically small: replaceJsonDecoder::decode($json, $schema)with anopisvalidator call plusjson_decode(..., JSON_THROW_ON_ERROR). Estimated effort: 1–3 engineer-days per integration surface.
How can I help you explore Laravel packages today?