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

1.0.0 2025-06-12 15:31 UTC

This package is auto-updated.

Last update: 2025-06-13 08:02:14 UTC


README

Latest Stable Version Total Downloads License Build Status

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

Advanced Guides

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