hoa/ruler
Hoa/ruler is a PHP rule engine for defining and evaluating business rules with a dedicated, expressive language. It supports stateless production rules, rule manipulation, proposition evaluation, and integration into PHP applications. Use it to model conditions and make declarative decisions.
hoa/ruler is a small, embeddable PHP expression engine: you write business conditions in a readable DSL (user.age > 18 and user.country in ['FR','BE']) and evaluate them against your own data. It replaces hand-rolled if chains and one-off configuration flags with a single, testable evaluation path. The realistic decision is not "adopt vs. build a DSL" but "vendor/fork this vs. build a DSL from scratch" — the parser, lexer, and AST are the expensive part you avoid writing.RuleEvaluator::evaluate(string $expression, array $context): bool) lets you ship the capability now and swap the engine later — to Symfony Expression Language, a managed rules service, or a DMN/decision-table engine — without rewriting call sites.Consider it when:
eval() — important if any rule text could ever come from a config file, customer admin, or tenant.Look elsewhere when:
each()-era idioms in older Hoa components) that you must patch yourself.Pragmatic read: treat the pattern as strategically valid and the package as a disposable accelerator. The adoption signals (archived, zero dependents) mean it should enter the codebase behind an interface and with a named maintainer, and never become a hard dependency in a long-lived product without a fork plan.
To executives (30 seconds): Today, changing a pricing threshold or an eligibility rule means an engineering ticket, a code review, and a release. This package lets those rules live as readable business expressions that ops or finance can change in configuration — faster experiments, fewer deploys, less engineering time spent on routine logic changes. The caveat: the open-source project is no longer maintained, so I recommend a two-week spike to prove the value, with the engine hidden behind an internal interface so we can replace it with a supported alternative without rework. Cost is low; the strategic win is validating whether "business logic without deploys" is worth funding properly.
To engineering: Small, embeddable, no runtime services. Rules compile to an AST and are evaluated in a sandbox — no eval. Custom operators and functions are straightforward to register, and it binds cleanly into Laravel's container as a singleton evaluator service. Expressions are readable enough to double as documentation and to unit-test directly. The honest trade-offs: abandoned since 2017, PHP 8 compatibility patches will be ours to carry, no security backports, and no performance work for high-volume paths. Proposal: vendor the source under app/Support/Rules, wrap it in a single RuleEvaluator contract, cover it with a compatibility test suite, and keep the swap to Symfony Expression Language or a managed engine as a one-file change.
To the business owner: You get a fast feedback loop on rule changes and a clear audit of what the logic is — but rule authoring stays with engineering for now. Self-serve editing, versioning, and approval workflows are a separate, larger investment this spike will help you size.
How can I help you explore Laravel packages today?