PHP code example of tankfairies / rulesengine

1. Go to this page and download the library: Download tankfairies/rulesengine library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tankfairies / rulesengine example snippets


use Tankfairies\Rulesengine\RulesEngine;

$this->rulesEngine = new RulesEngine('storage/rules');
$rulesEngine->setRule('var == 21');
$result = $rulesEngine->evaluate(['var' => 21]);

var == val OR var == 22
['var' => 20, 'val' => 20]

var !IN val
['var' => 20, 'val' => [21, 22, 23]]

var IN val AND var2 == "yes"
['var' => 22, 'val' => [21, 22, 23], 'var2' => 'yes']

var == 100 XOR group IN [123456, 456456]
['var' => '100', 'group' => 12121]