PHPackages                             mojolyon/axiom - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mojolyon/axiom

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mojolyon/axiom
==============

Business rule management system

v0.1.0(11y ago)019MITPHPPHP &gt;=5.3.0

Since Nov 20Pushed 11y ago1 watchersCompare

[ Source](https://github.com/mojoLyon/Axiom)[ Packagist](https://packagist.org/packages/mojolyon/axiom)[ RSS](/packages/mojolyon-axiom/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Axiom [![Build Status](https://camo.githubusercontent.com/ebc237cb3f3f5806a04f6f0c0280d1b41e7d66fa772924726f646fe0ccb1af3f/68747470733a2f2f7472617669732d63692e6f72672f6d6f6a6f4c796f6e2f4178696f6d2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/mojoLyon/Axiom)
===============================================================================================================================================================================================================================================================================

[](#axiom-)

a simple business rule management system for php
------------------------------------------------

[](#a-simple-business-rule-management-system-for-php)

Wikepedia definition :

> A **BRMS** or **Business Rule Management System** is a software system used to define, deploy, execute, monitor and maintain the variety and complexity of decision logic that is used by operational systems within an organization or enterprise. This logic, also referred to as business rules, includes policies, requirements, and conditional statements that are used to determine the tactical actions that take place in applications and systems.

Inspired by the book Enterprise Patterns and MDA written By Jim Arlow and Ila Neustadt

### Installation

[](#installation)

Add this in your `composer.json` :

```
{
    "require": {
        "mojolyon/axiom": "~0.1"
    }
}
```

### Usage

[](#usage)

```
// Setting rule with default values
$rule = new Rule('eligibleForDiscount');
$rule->add(new RuleElement\DateVariable('minCustomerSince', new \DateTime('2014-01-01 00:00:00')))
    ->add(new RuleElement\DateVariable('customerSince', new \DateTime('2014-01-01 00:00:00')))
    ->operator(Operator::GREATHER_THAN)
    ->variable('minOrder', 5)
    ->variable('customerNumberOrder', 0)
    ->operator(Operator::LESSERTHAN_OR_EQUAL)
    ->operator('and');

$ruleContext = new Context('eligibleForDiscountCustomer');
$ruleContext->add(new RuleElement\DateVariable('customerSince', new \DateTime('2013-12-11 22:00:00')))
            ->variable('customerNumberOrder', 13);

$isEligible = $rule->evaluate($ruleContext);

if ($isEligible->getValue()) {
    echo "Customer eligible for discount";
} else {
    echo "Customer not eligible for discount";
}

// will output "Customer eligible for discount"
// the rule is evaluate as : ((minCustomerSince > customerSince) and (minOrder
