square/laravel-hyrule
Laravel package from Square for defining expressive, reusable rules that determine whether a user can perform an action on a model. Rules live in their own classes with a fluent API, keeping authorization logic out of controllers and policies while integrating cleanly with Laravel.
Architecture fit — square/laravel-hyrule is a thin adapter that bridges Square's hyrule JSON Schema validator into Laravel's Illuminate\Contracts\Validation\Rule pipeline. It is a leaf dependency: it does not own persistence, queuing, or request lifecycle, so it slots cleanly into any Laravel app that already uses FormRequests or the Validator facade. The 3.0.0 release expands the adapter's surface by mapping more JSON Schema semantics (prohibited_if/unless, exclude_if/unless/with/without, missing_if/unless/with) onto Laravel-style conditional validation, which brings the bridge closer to parity with native Laravel rule behavior.
Integration feasibility — Low effort. Composer install, package auto-discovery (no manual provider registration in standard Laravel), then use as an inline rule or as a custom rule object inside rules(). The 3.0.0 headline is Laravel 10 support, so adoption on Laravel 10 is the intended happy path; teams on Laravel 8/9 should expect to stay on 2.3.1 unless the composer constraints say otherwise.
Technical risk — The major version bump (2.3.1 → 3.0.0) is the primary risk signal. Per semver, 3.0.0 almost certainly raises the minimum Laravel and PHP floors (Laravel 10 implies PHP 8.1+) and may drop older Laravel branches entirely — that is a breaking change for any app still on Laravel 8/9. Secondary risk is semantic drift: the newly supported rules (prohibited_if, exclude_with, missing_unless, etc.) have precise Laravel semantics, and mapping them to JSON Schema keyword semantics is non-trivial. Divergence between "Laravel rule behavior" and "JSON Schema behavior" in edge cases (empty vs. missing vs. null) is the most likely source of subtle production bugs.
Key questions
composer.json constraints in 3.0.0 (PHP floor, laravel/framework and illuminate/* ranges, square/hyrule version)?MessageBag with per-field keys, or a single blob?Stack fit — Targets Laravel 10 / PHP 8.1+. Compatible with FormRequests, inline Validator::make, Rule objects, and conditional rule builders. No queue, cache, or filesystem dependencies. Safe to add to an existing validation layer without touching HTTP kernels, middleware, or service providers.
Migration path — Two-step. First, complete the host-app Laravel 10 / PHP 8.1 upgrade (this is the forcing function). Then bump square/laravel-hyrule from 2.3.1 to 3.0.0. Do not attempt to upgrade the package first — 3.0.0 will not install against Laravel 9. If the app is stuck on Laravel 9, pin to ^2.3 and treat 3.0.0 as deferred technical debt. For teams already on Laravel 10, the bump is effectively a no-op unless they opt into the new conditional rules.
Compatibility — Verify sibling validation packages (e.g. custom rule registries, laravel-jsonschema-style wrappers, API-doc generators that introspect rules) still resolve. The new conditional keywords are additive, so existing schemas continue to work unchanged. Watch for square/hyrule core version pinning — a transitive major of the underlying validator would ripple through.
Sequencing
grep for the rule class / alias) and capture their JSON Schemas.square/laravel-hyrule to ^3.0 and re-run tests; diff any changed validation error strings.prohibited_if, exclude_*, missing_*) incrementally, behind feature tests that assert both pass and fail cases against known-good fixtures.Maintenance — Small, focused package; low ongoing maintenance footprint if version-pinned. However, it is a Square-maintained OSS project with a small contributor base (3.0.0 introduces one first-time contributor). Cadence appears release-driven rather than scheduled — 2.3.1 to 3.0.0 spans a meaningful gap. Pin to ^3.0 and review changelogs at each minor.
Support — GitHub issues only; no commercial SLA. Acceptable for a validation helper (failure is contained to request validation), not acceptable if schemas become a hard contractual boundary with external API consumers. Mitigation: vendor the package or fork if it becomes load-bearing.
Scaling — Per-request overhead is modest but non-zero: JSON Schema validation is heavier than native Laravel rules, and schema compilation may repeat per invocation. For high-throughput endpoints with complex schemas, benchmark before rollout and consider caching compiled schema objects at the app layer. No horizontal scaling concerns — stateless.
Failure modes
Ramp-up — Low for Laravel developers — the rule reads like any other validation rule. The real learning curve is JSON Schema authoring (draft version, $ref usage, conditional keywords), which is a skills gap separate from the package. Budget a short internal guide and a set of canonical schema examples before teams self-serve.
How can I help you explore Laravel packages today?