https://github.com/millipress/millirules
A declarative rule engine for PHP that turns complex conditional logic into readable "when-then" rules. Features a fluent builder API, lazy-loaded context for performance, smart operator inference, and works seamlessly in pure PHP or WordPress.
https://github.com/millipress/millirules
actions conditions fluent-api php rules wordpress
Last synced: 6 days ago
JSON representation
A declarative rule engine for PHP that turns complex conditional logic into readable "when-then" rules. Features a fluent builder API, lazy-loaded context for performance, smart operator inference, and works seamlessly in pure PHP or WordPress.
- Host: GitHub
- URL: https://github.com/millipress/millirules
- Owner: MilliPress
- License: other
- Created: 2025-11-11T13:41:33.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2026-04-29T09:57:51.000Z (about 1 month ago)
- Last Synced: 2026-04-29T11:27:42.610Z (about 1 month ago)
- Topics: actions, conditions, fluent-api, php, rules, wordpress
- Language: PHP
- Homepage: https://millipress.com/millirules
- Size: 790 KB
- Stars: 15
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MilliRules
A flexible, framework-agnostic rule evaluation engine for PHP 7.4+.
## Overview
MilliRules is a powerful rule engine that allows you to define complex conditional logic using a fluent API. It's designed to be framework-agnostic while providing specialized support for HTTP and WordPress environments.
## Features
- **Fluent API**: Build complex rules with an intuitive, chainable syntax
- **Framework Agnostic**: Core engine works with any PHP application
- **Lazy-Loaded Context**: On-demand loading of context data for optimal performance
- **HTTP Support**: Built-in conditions for request handling
- **WordPress Integration**: Native support for WordPress queries and context
- **Extensible**: Easy to add custom conditions and actions
- **Flexible Naming**: Use snake_case or camelCase — `when_all()` and `whenAll()` both work
- **PHP 7.4+ Compatible**: Works with PHP 7.4+, PHP 8.0+ recommended
## Installation
```bash
composer require millipress/millirules
```
## Quick Start
```php
use MilliRules\Rules;
// Simple HTTP rule
Rules::create('api_check')
->when()
->request_url('/api/*')
->then()
->custom( 'auth-check', function($context) {
// Your action here
})
->register();
```
## Documentation
See the [full documentation](https://millipress.com/docs/millirules/) for detailed guides and API reference.
## License
GPL-2.0-or-later