PHPackages                             fragoe/ddd-business-rules-specification - 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. fragoe/ddd-business-rules-specification

ActiveLibrary

fragoe/ddd-business-rules-specification
=======================================

Core library implementing the Specification Pattern for DDD business rules with composable boolean operations.

v1.0.2(4mo ago)01MITPHPPHP ^8.3CI passing

Since Dec 22Pushed 4mo agoCompare

[ Source](https://github.com/fragoe/ddd-business-rules-specification)[ Packagist](https://packagist.org/packages/fragoe/ddd-business-rules-specification)[ RSS](/packages/fragoe-ddd-business-rules-specification/feed)WikiDiscussions main Synced 1mo ago

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

DDD Business Rules Specification
================================

[](#ddd-business-rules-specification)

[![Tests](https://github.com/fragoe/ddd-business-rules-specification/actions/workflows/tests.yml/badge.svg)](https://github.com/fragoe/ddd-business-rules-specification/actions/workflows/tests.yml)[![codecov](https://camo.githubusercontent.com/01656e75771fcf07cdb643e4f2cbe7b96ebcc6762bd84ba9853c76bed6b7f703/68747470733a2f2f636f6465636f762e696f2f67682f667261676f652f6464642d627573696e6573732d72756c65732d73706563696669636174696f6e2f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/fragoe/ddd-business-rules-specification)[![PHP Version](https://camo.githubusercontent.com/ef0054230522e542bc1f908ac005c6c75888dea255bac910f9015e12095e31d7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e332d626c7565)](https://www.php.net/)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

A lightweight PHP library implementing the [Specification Pattern](https://en.wikipedia.org/wiki/Specification_pattern) for Domain-Driven Design. Compose business rules with a fluent API using `and()`, `or()`, `not()`, and `xor()`.

Installation
------------

[](#installation)

```
composer require fragoe/ddd-business-rules-specification
```

**Requirements:** PHP ^8.3

Usage
-----

[](#usage)

Extend `CompositeBusinessRule` and implement `isSatisfiedBy()`. Compose rules using the fluent API.

See [`tests/CompositeBusinessRulesTest.php`](tests/CompositeBusinessRulesTest.php) for comprehensive usage examples including rule creation, composition, and fluent chaining. For a real-world domain example, see [`tests/CoffeeExamplesTest.php`](tests/CoffeeExamplesTest.php).

Built-in Composites
-------------------

[](#built-in-composites)

ClassDescription`AndBusinessRule`All rules must be satisfied`OrBusinessRule`At least one rule must be satisfied`XorBusinessRule`Exactly one rule must be satisfied`NotBusinessRule`Inverts the rule resultDesign Philosophy
-----------------

[](#design-philosophy)

This library follows strict DDD principles and intentionally excludes infrastructure concerns. Database queries, visualization, and validation framework integration are handled by companion packages:

- [ddd-business-rules-doctrine](https://github.com/fragoe/ddd-business-rules-doctrine) - Doctrine bridge
- [ddd-business-rules-analyzer](https://github.com/fragoe/ddd-business-rules-analyzer) - Static analysis and visualization

Package Ecosystem
-----------------

[](#package-ecosystem)

PackageDescription[fragoe/ddd-business-rules](https://github.com/fragoe/ddd-business-rules)Meta package**fragoe/ddd-business-rules-specification**Core library (this package)[fragoe/ddd-business-rules-doctrine](https://github.com/fragoe/ddd-business-rules-doctrine)Doctrine bridge[fragoe/ddd-business-rules-validation](https://github.com/fragoe/ddd-business-rules-validation)Validation integration[fragoe/ddd-business-rules-analyzer](https://github.com/fragoe/ddd-business-rules-analyzer)Analysis toolsLicense
-------

[](#license)

MIT - See [LICENSE](LICENSE)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance77

Regular maintenance activity

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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 ~7 days

Total

3

Last Release

127d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fragoe-ddd-business-rules-specification/health.svg)

```
[![Health](https://phpackages.com/badges/fragoe-ddd-business-rules-specification/health.svg)](https://phpackages.com/packages/fragoe-ddd-business-rules-specification)
```

PHPackages © 2026

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