1. Go to this page and download the library: Download superruzafa/rules 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/ */
superruzafa / rules example snippets
$ctx = new Context();
$ctx['name'] = 'Philip J.';
$ctx['surname'] = 'Fry';
// If the context's name is 'Philip J.' AND the context's surname is 'Fry'...
$condition = new AndOp(
new EqualTo('{{ name }}', 'Philip J.'),
new EqualTo('{{ surname }}', 'Fry')
);
// Then print the message
$action = new RunCallback(function (Context $c) {
echo 'Hello, my name is ' . $c['name'] . $c['surname'];
});
$rule = new Rule();
$rule
->setCondition($condition)
->setAction($action)
->execute($ctx);
// Hello, my name is Philip J. Fry