steffenbrand/dmn-decision-tables
Composer 安装命令:
composer require steffenbrand/dmn-decision-tables
包简介
PHP library to programmatically create DMN decision tables.
关键字:
README 文档
README
DMN Decision Tables
PHP library to programmatically create DMN decision tables
Limitations
- Generated tables have been tested with Camunda BPM platform and Camunda Cloud, but have NOT been tested with any other BPMN engine
- Only FEEL and JUEL expressions have been tested yet
- Only one decision table is supported per .dmn-file
- No DRD features are supported
- IDs are generated randomly, as you can see from the examples below
How to install
composer require steffenbrand/dmn-decision-tables
How to use
These examples show how to build the Camunda Cloud example table
Build decision table
try { $decisionTable = DecisionTableBuilder::getInstance() ->setName('Dish') ->setDefinitionKey('decision') ->setHitPolicy(HitPolicy::UNIQUE_POLICY) ->addInput(new Input('Season', 'season', VariableType::STRING_TYPE)) ->addInput(new Input('How many guests', 'guests', VariableType::INTEGER_TYPE)) ->addOutput(new Output('Dish', 'dish', VariableType::STRING_TYPE)) ->addRule( [ new InputEntry('"Fall"', ExpressionLanguage::FEEL_LANGUAGE), new InputEntry('<= 8', ExpressionLanguage::FEEL_LANGUAGE) ], [new OutputEntry('"Spareribs"', ExpressionLanguage::JUEL_LANGUAGE)] ) ->addRule( [new InputEntry('"Winter"'), new InputEntry('<= 8')], [new OutputEntry('"Roastbeef"')] ) ->addRule( [new InputEntry('"Spring"'), new InputEntry('<= 4')], [new OutputEntry('"Dry Aged Gourmet Steak"')] ) ->addRule( [new InputEntry('"Spring"'), new InputEntry('[5..8]')], [new OutputEntry('"Steak"')], 'Save money' ) ->addRule( [new InputEntry('"Fall", "Winter", "Spring"'), new InputEntry('> 8')], [new OutputEntry('"Stew"')], 'Less effort' ) ->addRule( [new InputEntry('"Summer"'), new InputEntry(null)], [new OutputEntry('"Light Salad and a nice Steak"')], 'Hey, why not!?' ) ->build(); } catch (DmnValidationException $e) { // Build method validates before it creates the DecisionTable. // Can be disabled, so feel free to validate yourself. // Use the DecisionTableValidator or inject your own validator. } catch (DmnConversionException $e) { // Conversion to XML might fail because of invalid expressions or whatever. }
Convert to DMN string (XML)
$decisionTable->toDMN();
Save to filesystem
$decisionTable->saveFile('/my/path/and/filename.dmn');
What the result looks like
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn11.xsd" id="definitions" name="definitions" namespace="http://camunda.org/schema/1.0/dmn"> <decision id="decision" name="Dish"> <decisionTable id="decisionTable5990364503747" hitPolicy="UNIQUE"> <input id="input599036450376b" label="Season"> <inputExpression id="inputExpression5990364503774" typeRef="string"> <text>season</text> </inputExpression> </input> <input id="input5990364503786" label="How many guests"> <inputExpression id="inputExpression5990364503790" typeRef="integer"> <text>guests</text> </inputExpression> </input> <output id="output59903645037c4" label="Dish" name="dish" typeRef="string"/> <rule id="rule59903645037de"> <inputEntry id="inputEntry59903645037fb" expressionLanguage="feel"> <text><![CDATA["Fall"]]></text> </inputEntry> <inputEntry id="inputEntry5990364503816" expressionLanguage="feel"> <text><![CDATA[<= 8]]></text> </inputEntry> <outputEntry id="outputEntry5990364503833" expressionLanguage="juel"> <text><![CDATA["Spareribs"]]></text> </outputEntry> </rule> <rule id="rule5990364503847"> <inputEntry id="inputEntry5990364503880" expressionLanguage="feel"> <text><![CDATA["Winter"]]></text> </inputEntry> <inputEntry id="inputEntry59903645038bf" expressionLanguage="feel"> <text><![CDATA[<= 8]]></text> </inputEntry> <outputEntry id="outputEntry59903645038ee" expressionLanguage="juel"> <text><![CDATA["Roastbeef"]]></text> </outputEntry> </rule> <rule id="rule59903645038fc"> <inputEntry id="inputEntry599036450390a" expressionLanguage="feel"> <text><![CDATA["Spring"]]></text> </inputEntry> <inputEntry id="inputEntry5990364503916" expressionLanguage="feel"> <text><![CDATA[<= 4]]></text> </inputEntry> <outputEntry id="outputEntry5990364503922" expressionLanguage="juel"> <text><![CDATA["Dry Aged Gourmet Steak"]]></text> </outputEntry> </rule> <rule id="rule5990364503930"> <description>Save money</description> <inputEntry id="inputEntry599036450393e" expressionLanguage="feel"> <text><![CDATA["Spring"]]></text> </inputEntry> <inputEntry id="inputEntry599036450394d" expressionLanguage="feel"> <text><![CDATA[[5..8]]]></text> </inputEntry> <outputEntry id="outputEntry5990364503961" expressionLanguage="juel"> <text><![CDATA["Steak"]]></text> </outputEntry> </rule> <rule id="rule599036450396e"> <description>Less effort</description> <inputEntry id="inputEntry599036450397b" expressionLanguage="feel"> <text><![CDATA["Fall", "Winter", "Spring"]]></text> </inputEntry> <inputEntry id="inputEntry5990364503985" expressionLanguage="feel"> <text><![CDATA[> 8]]></text> </inputEntry> <outputEntry id="outputEntry5990364503991" expressionLanguage="juel"> <text><![CDATA["Stew"]]></text> </outputEntry> </rule> <rule id="rule599036450399d"> <description>Hey, why not!?</description> <inputEntry id="inputEntry59903645039ab" expressionLanguage="feel"> <text><![CDATA["Summer"]]></text> </inputEntry> <inputEntry id="inputEntry59903645039b4"> <text/> </inputEntry> <outputEntry id="outputEntry59903645039c0" expressionLanguage="juel"> <text><![CDATA["Light Salad and a nice Steak"]]></text> </outputEntry> </rule> </decisionTable> </decision> </definitions>
Try it
Feel free to download generated_with_dmn_decision_tables.dmn and try it in the Camunda Cloud
steffenbrand/dmn-decision-tables 适用场景与选型建议
steffenbrand/dmn-decision-tables 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.06k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2017 年 08 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「camunda」 「bpmn」 「DMN」 「Decision Table」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 steffenbrand/dmn-decision-tables 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 steffenbrand/dmn-decision-tables 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 steffenbrand/dmn-decision-tables 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The library provides us with a frame to build a workflow or a business process such as BPMN. Could execute tasks in parallel or delayed tasks
PHP SDK for camundaBPM process services
Implementation of XML model - the core of BPMN engine
Bpmn model used in workflow engine
Just another BPMN engine for workflow and process automation
PHP SDK for Camunda BPM engine rest service
统计信息
- 总下载量: 17.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 20
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-08-13