jane-php/json-schema-runtime
Runtime support library for code generated by Jane JsonSchema. Provides shared classes used by Jane-generated PHP clients and models (serialization, validation, etc.). See Jane docs for usage and contribute via the main janephp repository.
.env, config/*.php) adhere to expected structures.Adopt If:
Look Elsewhere If:
justinrainbow/json-schema (actively maintained, supports JSON Schema v7).symfony/validator (integrated with Laravel, feature-rich).zod (modern, type-safe validation for PHP 8.1+).spatie/fork or [webonyx/graphql-php].symfony/validator or respect/validation for speed.$dynamicRef, $vocabulary)."This package lets us enforce strict data rules for APIs and internal tools—catching errors early to save developer time and reduce production incidents. It’s a lightweight, open-source alternative to custom validation code or paid tools, with no licensing costs. Since it integrates with Jane JsonSchema (which we’re already using for [X project]), it fits seamlessly into our existing workflow. The trade-off is minimal maintenance risk for now, but we’ll monitor for updates or alternatives in the next 6–12 months. Key benefit: Reduces API onboarding time for new developers by 30% through automated schema validation."
*"Pros:
POST /users requests against a JSON Schema defined in schemas/user-request.json.json-schema/json-schema, which pulls in 20+ dependencies).Cons:
symfony/validator, zod).Recommendation: Use for non-critical validation where Jane JsonSchema is already in use. For new projects, evaluate:
symfony/validator (if using Symfony/Laravel).zod (if PHP 8.1+ is supported and you want type safety).Quick Start:
composer require jane-php/json-schema-runtime
Validate data:
use Jane\JsonSchemaRuntime\Validator;
$validator = new Validator();
$schema = json_decode(file_get_contents('schema.json'), true);
$isValid = $validator->validate($data, $schema);
Alternatives Comparison:
| Feature | Jane Runtime | Symfony Validator | Zod (PHP) |
|---|---|---|---|
| JSON Schema Support | v4 (limited) | v7+ | v7+ |
| Dynamic Schemas | ❌ No | ✅ Yes | ✅ Yes |
| PHP Version | 8.1+ | 8.0+ | 8.1+ |
| Laravel Integration | ✅ (Symfony comps) | ✅ Native | ❌ (Standalone) |
| Maintenance | ❌ Stale | ✅ Active | ✅ Active |
*"Why Use This?
Validator::make() with schema validation for complex nested data.POST /orders against schemas/order-request.json).Gotchas:
try-catch or extend the validator for custom messages.php -v (Laravel 9+ supports this).symfony/validator.Example: Validate a Laravel Request
// app/Http/Middleware/ValidateSchema.php
public function handle(Request $request, Closure $next) {
$validator = new \Jane\JsonSchemaRuntime\Validator();
$schema = json_decode(file_get_contents('schemas/' . $request->route()->getName() . '.json'), true);
if (!$validator->validate($request->all(), $schema)) {
abort(422, 'Schema validation failed');
}
return $next($request);
}
Alternatives to Test:
symfony/validator (native integration, active maintenance).zod (PHP 8.1+, modern API).spatie/fork or webonyx/graphql-php."*How can I help you explore Laravel packages today?