Download the PHP package kennyth01/php-rules-engine without Composer
On this page you can find all versions of the php package kennyth01/php-rules-engine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kennyth01/php-rules-engine
More information about kennyth01/php-rules-engine
Files in kennyth01/php-rules-engine
Package php-rules-engine
Short Description A PHP rules engine inspired by CacheControl/json-rules-engine, enabling dynamic rule evaluation based on conditions and facts.
License MIT
Informations about the package php-rules-engine
PHP Rules Engine
kennyth01/php-rules-engine
is a lightweight and flexible PHP rules engine that evaluates complex conditional logic using JSON-based rule configurations. It is designed to handle dynamic, reusable, and maintainable rule logic, making it ideal for applications with complex business requirements that must adapt to changing conditions.
This library, inspired by the json-rules-engine
, (link) enables developers to define rules with nested conditions, logical operators (all
, any
, not
), and rule dependencies.
Features
- JSON-Configurable Rules: Easily define rules and conditions in JSON format.
- Rule Dependencies: Reference other rules as conditions to create complex evaluations.
- Logical Operators: Supports
all
(AND),any
(OR), andnot
operators, allowing for nested conditions. - Custom Events and Failure Messages: Attach custom messages for success or failure, making evaluations easy to interpret.
- Interpret Rules: Outputs a human readable English interpretation of the condition using logical operators.
Installation
Install via Composer:
Basic Example
This example demonstrates an engine for detecting whether a basketball player has fouled out (a player who commits five personal fouls over the course of a 40-minute game, or six in a 48-minute game, fouls out).
- Define the rule (lets assume you store this in
rule.player.isFouledOut.json
)
- Trigger the engine and evaluate
- Output Example
Advanced Examples
For other examples, refer to the tests
directory
Run the test
License
ISC