mrsuh/json-validation-bundle
A Symfony bundle for validating JSON documents against JSON Schema. Add schema-based validation to request payloads, forms, and APIs with a dedicated constraint and clear, actionable error messages.
Architecture fit — low for direct adoption, moderate for pattern reuse. The package is packaged as a Symfony bundle, not a framework-agnostic library. Its entry point (*Bundle class), DI extension, configuration tree, and request/response event subscribers are all bound to the Symfony kernel lifecycle. Laravel has no equivalent contract: bundles do not autoload, services.yaml is not consumed, and Laravel ships its own event dispatcher and container. The usable asset is the validation core — schema loading plus validation of decoded JSON payloads — not the integration layer. In a Laravel context, the equivalent surface is a middleware (request) and a test-time assertion (response), or a custom Rule object wired into FormRequests.
Integration feasibility — conditional. Two paths exist:
opis/json-schema, justinrainbow/json-schema, or a bespoke validator) and depend on that directly, reimplementing ~100 lines of Laravel glue (middleware + service provider + exception handler mapping). Highest leverage, lowest dependency risk.symfony/http-kernel, symfony/config, and symfony/dependency-injection — http-kernel is not a Laravel dependency, so this introduces a parallel HTTP kernel stack purely as a transitive cost.Technical risk — elevated, concentrated in stewardship. 17 stars, 0 dependents, a single release cadence that stopped in March 2023. There is no evidence of testing against PHP 8.3/8.4 or Symfony 7, no security response process, and no downstream population to surface regressions. MIT licensing removes legal friction but not maintenance obligation. The codebase is small enough to audit in an afternoon, which materially lowers supply-chain risk — the exposure is abandonment, not malice.
Key questions to resolve before commitment
$ref resolution across files/URLs, and is remote $ref fetching disabled by default?Stack fit. Laravel 10/11/12 pins Symfony components at ^6/^7. If the bundle requires symfony/http-kernel ^4|^5, Composer will either fail or force a downgrade of core Laravel dependencies — an unacceptable outcome. Verify the constraint set on a scratch branch before any design work; a resolution failure here ends the evaluation in under an hour.
Migration path. Treat this as a pattern adoption, not a package adoption, unless the spike proves otherwise:
Compatibility. Pin the forked package at an exact version, add a CI job that runs the full test suite against the current and next PHP minor, and record the supported draft in the composer manifest. Do not accept floating constraints on a package with zero dependents and no release in two years.
Sequencing. Schema-first, enforcement-last. Authoring schemas and wiring CI assertions is reversible and high-value; rejecting live traffic is not. Enforce per-endpoint behind a feature flag so rollback is a config change rather than a deploy.
Maintenance. Assume fork-and-own. Budget 1–2 engineer-days per quarter for dependency bumps, PHP minor compatibility, and schema-engine security patches. Track upstream via a watch on the repository; if it stays dormant for another two release cycles, formally reclassify it as an internal library and remove the upstream link from the dependency graph.
Support. No vendor, no SLA, community-of-one. The internal runbook must cover: how schemas are versioned, how to read a validation failure, how to disable enforcement per route, and who approves schema changes. Escalation path terminates at the owning team, not at an upstream maintainer.
Scaling. Schema validation is CPU-bound and runs per request. Compile or cache validators at boot — recompiling a schema graph per request will dominate p95 on high-throughput endpoints. Watch payload size: decoding plus validating a multi-megabyte body has a memory cost that is easy to miss in load tests. Response validation should never run in production paths; it multiplies cost by response count and returns no runtime safety.
Failure modes.
$ref DoS — adversarial or careless schemas can produce catastrophic backtracking or unbounded recursion.$ref fetch — must be disabled, or validation becomes a network call and an SSRF vector.Ramp-up. One to two days for a mid-level engineer to become productive; the real cost is JSON Schema literacy (drafts, $ref semantics, composition keywords), which is a team-level skill investment of roughly a week and is transferable to OpenAPI work regardless of whether this package survives the evaluation.
Recommendation. Adopt the capability, not the bundle. Fund the two-day spike to identify the underlying schema engine; proceed only if it extracts cleanly into Laravel-native middleware. If extraction is not clean, the correct decision is a first-party middleware over a maintained schema validator, with this repository retained as a design reference.
How can I help you explore Laravel packages today?