- What is ergebnis/json-schema-validator used for in a Laravel application?
- It validates JSON documents against a JSON Schema and returns a result object where you call isValid() and errors() to get a flat list of ValidationError value objects. Laravel teams reach for it when Laravel's built-in rule set is too loose for strict data contracts such as third-party API payloads, configuration files, and test fixtures. Because it is framework-agnostic, you typically wrap it in a custom Rule or call it from a service class.
- How do I install ergebnis/json-schema-validator with Composer?
- Run composer require ergebnis/json-schema-validator. There is no service provider, facade, or config file to publish, so installation is just the Composer dependency. Check the package's composer.json require block against your CI matrix, since PHP compatibility is the only real constraint.
- Can I use ergebnis/json-schema-validator inside Laravel Form Requests?
- Yes. Implement a custom rule that satisfies Laravel's ValidationRule contract, run the schema validator inside it, and translate the returned ValidationError objects into a failure message or ValidationException. This keeps strict JSON Schema semantics available wherever you already validate request data. It is not a Laravel package, so there is no facade or service provider to register, only your own wrapper.
- How do I get structured validation errors instead of nested arrays?
- Build a Json instance with Json::fromString or Json::fromFile, create a Pointer\JsonPointer::document() pointer, and pass both plus the schema to SchemaValidator::validate(). The returned result exposes isValid() as a boolean and errors() as a flat list of ValidationError value objects, which map cleanly onto your API error format. The validator is stateless, so you can reuse one instance across requests.
- Which JSON Schema drafts does ergebnis/json-schema-validator support, including Draft 7 and 2020-12?
- The 4.6.0 release notes announce no changes to schema draft support, and the package delegates validation to justinrainbow/json-schema, which historically targets Draft 3 through Draft 7. Draft 2020-12 support is not confirmed in the release notes, so verify it with a smoke test before designing new schemas around it. If you need 2020-12 keywords, either design defensively against the draft you have confirmed or evaluate a different validator.
- What PHP and Laravel versions does version 4.6.0 support?
- The package is PHP-only and Laravel-version-agnostic, so it works with any Laravel release whose PHP constraint matches the package's composer.json. Version 4.6.0 adds official PHP 8.5 support, widening the runtime matrix rather than shifting policy. Confirm PHP 8.5 in staging before promoting it, since the rest of your stack may not be ready.
- Does upgrading to ergebnis/json-schema-validator 4.6.0 require migration steps?
- No. Version 4.6.0 introduces no public API changes, no signature changes, and no configuration changes, so composer update is the entire upgrade. Pin ^4.6 in composer.json and run your test suite plus one schema validation smoke test. Most of the release content is CI and tooling churn on the maintainer side.
- How does ergebnis/json-schema-validator perform with large payloads or deeply nested schemas?
- The package publishes no benchmarks, and 4.6.0 contains no performance work, so throughput for payloads over 1MB or deeply nested schemas is unmeasured. Benchmark representative documents in staging before relying on it for high-volume endpoints. For very large JSON documents, validating a normalized subset is usually the safer design.
- Is ergebnis/json-schema-validator production-ready and actively maintained?
- Maintenance signals are strong: 4.6.0 adds PHP 8.5 support, the CI pipeline includes zizmor supply-chain analysis, and dependency updates are auto-merged. The remaining risk is spec coverage and reference resolution, not abandonment. Pin the major version and review release notes for validator behavior changes rather than CI-only churn.
- What are the alternatives to ergebnis/json-schema-validator for JSON schema validation in PHP?
- The main options are using justinrainbow/json-schema directly, opis/json-schema, and swaggest/php-json-schema. The ergebnis package's value is a friendly, stateless interface with a flat list of ValidationError value objects and JsonPointer-based targeting, which is easier to map to API responses than raw nested arrays. Compare draft support and reference handling against your schemas before switching.