fly321/rule-engine
Composer 安装命令:
composer require fly321/rule-engine
包简介
通用规则引擎
README 文档
README
Rule Engine
这是一个简单的PHP规则引擎包。该项目使用PHP和Composer来构建和运行规则引擎。
需要
- PHP 7.4 or higher
- Composer
安装
-
require composer
composer require fly321/rule-engine
-
具体示例demo
php test/demo.php
use
规则引擎 - 实现RuleInterface接口
<?php namespace Fly\RuleEngine\Rules; use Fly\RuleEngine\Interfaces\RuleContextInterface; use Fly\RuleEngine\Interfaces\RuleInterface; class DemoRule implements RuleInterface { /** * @inheritDoc */ public function matches(RuleContextInterface $context): bool { return $context->containsKey("num1") && $context->containsKey("num2") && $context->get("num1") < $context->get("num2"); } /** * @inheritDoc */ public function execute(RuleContextInterface $context): void { var_dump($context->get("num1"), $context->get("num2")); echo "num1 < num2\n"; $context->set("num_bool", true); } /** * @inheritDoc */ public function notMatches(RuleContextInterface $context): void { var_dump($context->get("num1"), $context->get("num2")); echo "num1 >= num2\n"; $context->set("num_bool", false); } }
fly321/rule-engine 适用场景与选型建议
fly321/rule-engine 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fly321/rule-engine 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fly321/rule-engine 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 13
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-28