PHPackages                             mcneely/rulesengine - 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. mcneely/rulesengine

ActiveLibrary

mcneely/rulesengine
===================

description

00PHP

Since Dec 6Pushed 4y ago2 watchersCompare

[ Source](https://github.com/mcneely/RulesEngine)[ Packagist](https://packagist.org/packages/mcneely/rulesengine)[ RSS](/packages/mcneely-rulesengine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

RulesEngine
===========

[](#rulesengine)

Proof Of Concept for a PHP Rules engine with Drools inspired rules.

Usage:

```
        // initialise rules engines with the top of the directory containing namespaced rule files. Ex: __DIR__ . "/../Fixtures/namespaces"
       $rulesEngine = new RulesEngine(__DIR__ . "/../Fixtures/namespaces"[, EventDispatcher $eventDispatcher]);
       // add facts to provide information to the rules engine via class, array, etc.
       $rulesEngine->addFact(
       'SimpleObject', [
            $value => 0,
            $hasPassed => false
       ]);

       //Set the Namespace, this loads all rules  in the hierarchy of the namespace.
       $rulesEngine->setNamespace('Org\Test');

        // Optionally pass in a PSR-3 Compliant logger.
       $rulesEngine->setLogger(new Logger());

       // Run the rules on the facts
       $rulesEngine->run();
```

Sample Rule File (.rf.yml):

```
namespace: Org\Test
rules:
  'Simple Object Rule':
    when:
      # When an evaluation line is prefixed with ":"  the result
      # is stored as a fact that can be referenced later.
      - obj: 'SimpleObject'
      - 'obj.value == 42'
    then:
      - 'SimpleObject.hasPassed = true'

  'Simple Object Two Rule':
    when:
      'SimpleObjectTwo.getValue() == 5555'
    then:
      - 'SimpleObjectTwo.setString("Woo!")'
```

Note: More examples can be found in the `tests/Fixtures/namespaces` directory.

Event Listeners:

Several are triggered throughout the lifecycle of a rule. These events currently exist in the `src/Events` folder and can be listened for by optionally passing the Symfony EventDispatcher to the constructor. Future Versions may allow for the trigger of custom events from within rules.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c02254bd9d4ea76e8e32a3ddc98febf245033c4dae5aa2ab1f186c3a77ad3ea0?d=identicon)[mcneely](/maintainers/mcneely)

---

Top Contributors

[![mcneely](https://avatars.githubusercontent.com/u/4010314?v=4)](https://github.com/mcneely "mcneely (4 commits)")

### Embed Badge

![Health badge](/badges/mcneely-rulesengine/health.svg)

```
[![Health](https://phpackages.com/badges/mcneely-rulesengine/health.svg)](https://phpackages.com/packages/mcneely-rulesengine)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
