PHPackages                             cyve/rule-engine - 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. cyve/rule-engine

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

cyve/rule-engine
================

Rule Engine service

2.1.2(2y ago)014.5k↓65.6%1MITPHPPHP ^7.1|^8.0

Since May 17Pushed 2y ago1 watchersCompare

[ Source](https://github.com/cyve/rule-engine)[ Packagist](https://packagist.org/packages/cyve/rule-engine)[ RSS](/packages/cyve-rule-engine/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (7)Used By (0)

Rule engine
===========

[](#rule-engine)

Installation:
-------------

[](#installation)

With [Composer](http://packagist.org):

```
composer require cyve/rule-engine
```

Usage
-----

[](#usage)

```
use Cyve\RuleEngine\Engine\RuleEngine;
use Cyve\RuleEngine\Rule\ExpressionRule;

$engine = new RuleEngine([new ExpressionRule('subject * context["quantity"]')]);
$price = $engine->handle(100, ['quantity' => 2]); // 200
```

Use case: price calculator (for Symfony)
----------------------------------------

[](#use-case-price-calculator-for-symfony)

```
// src/Price/Rule/QuantityRule.php

namespace App\Price\Rule;

class QuantityRule
{
    public function __invoke($subject, array $context = [])
    {
        return $subject * $context['quantity'] ?? 1;
    }
}
```

```
// src/Price/Rule/PromoCodeRule.php

namespace App\Price\Rule;

class PromoCodeRule implements \Cyve\RuleEngine\Rule\RuleInterface
{
    public function supports($subject, array $context = []): bool
    {
        return isset($context['promoCode']);
    }

    public function handle($subject, array $context = [])
    {
        switch($context['promoCode']){
            case '10_PERCENT': return $subject * .9;
            default: return $subject;
        }
    }
}
```

```
// src/Price/PriceCalculator.php

namespace App\Price;

class PriceCalculator extends \Cyve\RuleEngine\Engine\RuleEngine
{}
```

```
# config/service.yml
# @see https://symfony.com/doc/4.4/service_container/tags.html#reference-tagged-services
App\Price\Rule\:
    resource: '../src/Price/Rule/*'
    tags: ['price.rule']
App\Price\PriceCalculator:
    public: true
    arguments:
        - !tagged_iterator price.rule
```

```
// src/Controller/DefaultController.php
...
public function priceAction()
{
    $unitPrice = 100;

    $calculator = $this->get(PriceCalculator::class);
    $price = $calculator->handle($unitPrice, ['quantity' => 2, 'promoCode' => '10_PERCENT'])); // 180
}
...
```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity72

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~438 days

Recently: every ~373 days

Total

6

Last Release

777d ago

Major Versions

1.1.0 → 2.0.02020-04-15

PHP version history (3 changes)1.0PHP ^7.0

1.1.0PHP ^7.1

2.1.1PHP ^7.1|^8.0

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

rule-engine

### Embed Badge

![Health badge](/badges/cyve-rule-engine/health.svg)

```
[![Health](https://phpackages.com/badges/cyve-rule-engine/health.svg)](https://phpackages.com/packages/cyve-rule-engine)
```

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.9k69.5k](/packages/grumpydictator-firefly-iii)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[verbb/formie

The most user-friendly forms plugin for Craft.

102393.6k69](/packages/verbb-formie)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

54681.3k18](/packages/solspace-craft-freeform)[blackfire/player

A powerful web crawler and web scraper with Blackfire support

49617.1k](/packages/blackfire-player)[typo3/cms-form

TYPO3 CMS Form - Flexible TYPO3 frontend form framework that comes with a backend editor interface.

147.6M265](/packages/typo3-cms-form)

PHPackages © 2026

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