skie / rule-flow
RuleFlow plugin for CakePHP
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=8.3
- cakephp/cakephp: ^5.1
Requires (Dev)
- cakephp/cakephp-codesniffer: ^5.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5
This package is auto-updated.
Last update: 2025-06-13 08:02:14 UTC
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