frontastic/rulerz
frontastic/rulerz is a PHP rule engine and specification library for writing business rules once as reusable predicates and applying them to arrays, query builders, and other data sources. Use its concise DSL or PHP rules for filtering, validation, and dynamic access control.
if block in a checkout service — each with a name, an owner, and a unit test.and/or/not apply equally to content targeting, feature gating, and email audience definitions — one mental model across features, lower onboarding cost.Adopt (or spike) when:
Look elsewhere, or proceed only with an ownership plan, when:
k-phoen/rulerz first and treat this fork as a patch source. Verify last commit, PHP version support vs. your runtime, open issues, and whether it still pulls the effectively-unmaintained hoa/* compiler.filter() over Collections works today; compiling specs to Illuminate\Database\Query\Builder requires a custom target (roughly 200–400 LOC) or a Doctrine DBAL bridge.Minimum due diligence before commitment: license compatibility (MIT — fine), security advisory history, PHP/Laravel version matrix, adapter coverage for your datastores, a timeboxed spike converting three real production rules, and a written exit plan (rules as plain classes behind an interface so the engine is swappable).
For executives (one paragraph): We repeatedly pay engineering to hard-code commercial logic — promotions, eligibility, product visibility, audience targeting — and each change is a ticket plus a release. This library lets us express those rules once, in a testable form, and run them identically against our database, our search index, and our tests. The upside is faster commercial iteration and fewer "the discount fired twice" incidents. The caveat is material: it is a low-adoption fork of a dormant open-source project, so we would adopt it behind our own interface with a named owner and a fallback plan. Recommendation: fund a two-week spike, not a commitment — the decision to make now is "encode rules as composable objects," which is defensible regardless of whether this specific library survives.
For engineering: This gives you the Specification pattern with a real DSL — composable and/or/not, named rules, adapters for arrays/Doctrine/search — replacing condition-soup in services with small, individually unit-tested classes and one rule definition executed consistently across test and production paths. Costs: a dependency on an unmaintained-adjacent fork (audit it, consider upstream first), a learning curve on the DSL, no built-in persistence or caching, and no first-party Eloquent/Scout target. Mitigation: define a thin internal SpecificationEngine interface bound as a singleton, keep rules as plain PHP objects, install via a VCS repository pinned to a commit SHA and mirror into an internal namespace, and vendor the fork if needed. That containment makes the library a replaceable implementation detail rather than an architectural bet — a future swap to symfony/expression-language or a hand-rolled predicate tree becomes an internal refactor.
For product and commercial teams: You gain a shared, precise vocabulary for rules and a much shorter path from "change the eligibility criteria" to "it's live." You do not gain a self-service rule editor — that remains a separate roadmap item, with this package as one input to it.
How can I help you explore Laravel packages today?