carsdotcom/laravel-json-schema
Adds JSON Schema validation to Laravel, letting you validate request data and other payloads against reusable schemas with Laravel-native errors—ideal for enforcing API contracts and keeping payload rules consistent.
normalizeWithJsonSerializable flag (defaulting to true, so drop-in compatible) gives teams a deliberate trade-off between fidelity and memory/speed. This matters for APIs handling large JSON payloads, bulk exports, reporting endpoints, and high-throughput message serialization where memory ceilings and latency budgets are real constraints.JsonSerializable, Eloquent Models, and JsonModel contracts), teams can adopt this package and gain a supported escape hatch — flip the flag to use the faster, lower-memory Opis\Helper::toJson path for the 90% of payloads that aren't exotic.JsonSerializable objects, or (b) throughput-optimized encoding of very large payloads. It is less central when payloads are always small and structured.false in memory-constrained workers (queue consumers, Lambda/containers with tight memory limits) without forking the library, reducing the risk of OOM crashes in production.Adopt it when:
JsonSerializable objects, and want a maintained library rather than bespoke json_encode plumbing.Look elsewhere (or scope tightly) when:
json_encode or Laravel's built-in resource/serialization features may suffice without an extra dependency.JsonSerializable contracts (custom Eloquent casts, JsonModel implementations) that the Opis\Helper::toJson fast path does not fully honor — you must keep the flag true and lose the memory benefit.For executives: This release is a low-risk, high-value enhancement. Default behavior is unchanged, so upgrades carry no migration cost, while teams gain an opt-in performance lever for large payloads — directly relevant to infrastructure cost and reliability (fewer memory-related failures). It reinforces the case for buying a maintained serialization library rather than building one.
For engineering: The new normalizeWithJsonSerializable flag (default true) preserves the existing high-fidelity normalization path, including Eloquent Models and JsonModel contracts. Setting it to false switches to Opis\Helper::toJson, which is faster and less memory-intensive but bypasses unusual JsonSerializable contracts. Recommended usage: keep true by default for correctness, and set false deliberately in memory-constrained or high-throughput contexts where the payload shape is known-simple. Action items: benchmark against representative production payloads before flipping the default, and document which code paths depend on the high-fidelity path.
How can I help you explore Laravel packages today?