skie/rule-flow
最新稳定版本:1.0.0
Composer 安装命令:
composer require skie/rule-flow
包简介
RuleFlow plugin for CakePHP
README 文档
README
A CakePHP plugin that seamlessly transforms server-side validation rules into client-side JSON Logic validation, providing automatic form validation without requiring separate client-side validation code.
Features
- Automatic Rule Transformation: Converts CakePHP validation rules to JSON Logic format
- Real-time Validation: Client-side validation with immediate feedback
- Custom Rules Support: Extend with custom PHP rules and JavaScript functions
- Dynamic Forms: Support for dynamically added form fields
- Zero Configuration: Works automatically with enhanced FormHelper
- Cross-Platform Patterns: Consistent regex validation between PHP and JavaScript
Quick Start
Installation
composer require skie/rule-flow
Basic Usage
1. Load the plugin in your CakePHP application:
// In config/bootstrap.php or Application.php $this->addPlugin('RuleFlow');
2. Use in your controller:
// Load the component public function initialize(): void { parent::initialize(); $this->loadComponent('RuleFlow.Rule'); } // Configure validation rules for forms public function add() { $article = $this->Articles->newEmptyEntity(); $this->Rule->configureFormRules($this->Articles); $this->set(compact('article')); }
3. Use enhanced FormHelper in your view:
// In src/View/AppView.php public function initialize(): void { parent::initialize(); $this->loadHelper('RuleFlow.Form'); }
4. Create forms with automatic validation:
<?= $this->Form->create($article) ?> <?= $this->Form->control('title') ?> <?= $this->Form->control('content') ?> <?= $this->Form->button('Submit') ?> <?= $this->Form->end() ?>
That's it! Your forms now have automatic client-side validation based on your CakePHP validation rules.
Documentation
Core Documentation
- Plugin Documentation - Complete guide to using the plugin
- JsonLogic Operations Reference - All available JsonLogic operations
Advanced Guides
- Custom Rules Guide - Creating custom validation rules and functions
- Regex Compatibility Guide - Cross-platform regex patterns
Requirements
- PHP: 8.3+
- CakePHP: 4.5+
- Browser: Modern browsers with ES6+ support
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Links
- Packagist
- GitHub Repository
- Issues
- JSON Logic - The underlying rule engine
统计信息
- 总下载量: 174
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-12