Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ruler Laravel Package

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.

View on GitHub
Deep Wiki
Context7

The Hoa\Ruler library.

Frequently asked questions about Ruler
What is hoa/ruler and how does it work in a Laravel application?
hoa/ruler is a framework-agnostic PHP rule engine from the Hoa project. You pass a rule written in its own DSL, such as logged(user) and user.age > 18, together with a context array or object, and it returns a boolean. In Laravel you would wrap it behind your own service class or contract rather than calling the library directly from controllers. It is a parser and evaluator only, so persistence, versioning, an authoring UI and audit trails are all yours to build.
How do I install hoa/ruler with Composer?
Run composer require hoa/ruler and Composer will also pull the wider Hoa dependency tree, including hoa/compiler, hoa/ustring, hoa/visitor, hoa/stream and hoa/consistency. There is no Laravel service provider, facade or config file, so you need to register your own binding. Because the dependency set is old, pin it and commit your composer.lock.
Which PHP and Laravel versions does hoa/ruler support?
There is no official Laravel support matrix; the library is framework-agnostic and its last release was 2.17.05.16 on 2017-05-16. That predates PHP 8, and transitive dependencies such as hoa/compiler and hoa/ustring are known to hit deprecations and removals introduced in PHP 8.1 and later. Test on your target PHP version before committing, and be prepared to fork or pin.
How do I evaluate a hoa/ruler rule against Eloquent models or request data?
The evaluator expects a context of arrays or objects matching the shape your rule references. Since 2.17.05.16 the asserter can traverse array-like dimensions, so ArrayAccess implementations such as ArrayObject and some value objects can be visited directly. Eloquent models are a heterogeneous mix of attributes, casts and relations, so normalising them into a predictable context shape remains the bulk of the integration work.
Does hoa/ruler work with Laravel Octane?
Hoa bootstraps a custom hoa:// stream wrapper and constants at autoload time, which adds a side effect to the request lifecycle. In a long-lived worker environment such as Octane this needs explicit testing; at minimum make sure the Hoa bootstrap happens once per worker rather than on every request. Many teams treat this as a reason to isolate the engine behind their own interface.
Is hoa/ruler still maintained and is it safe to use in a Laravel app?
The GitHub repository is archived, the Hoa project itself is disbanded, and the latest release is from May 2017. There is no security response process and no PHP 8.x maintenance, and the 2.17.05.16 note is a single-commit feature release rather than evidence of renewed activity. The BSD-family licence (verify it yourself) permits a fork, but it does not give you free maintenance.
What are the alternatives to hoa/ruler for business rules in Laravel?
Start by asking whether a DSL is genuinely required, because decision tables stored in JSON or config cover many eligibility, pricing and feature-gating cases with less risk. If you do need expression evaluation, compare against maintained expression-language libraries and check their PHP 8 support and release cadence. Whichever you choose, define your own RuleEngine contract so the underlying engine stays replaceable.
How should I validate hoa/ruler rules before evaluating them?
Parse and validate rules at write time, not at evaluation time, so a malformed expression never reaches production traffic. Keep the allowed DSL surface in config, including permitted functions, operators and context keys, and reject anything outside it. If evaluation volume is high, cache parsed rules instead of recompiling the same expression on every request.
How do I test rules written for hoa/ruler?
Treat rules as data and unit test each one against representative contexts, including missing keys, null values and boundary comparisons. Add tests that pin the behaviour of ArrayAccess contexts, because the library does not document what happens when a dimension is absent or when an implementation throws. Contract tests on your own RuleEngine interface also make it possible to swap engines later without rewriting call sites.
Does hoa/ruler provide an audit trail or explain why a rule matched?
No. The library returns a boolean from Ruler::assert and offers no evaluation audit trail, versioning or explainability output. If compliance requires per-evaluation records or answers to why did this match, you must build that layer yourself, for example by logging context snapshots and rule versions alongside the result.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console