Download the PHP package jmjjg/cakephp3-database without Composer
On this page you can find all versions of the php package jmjjg/cakephp3-database. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jmjjg/cakephp3-database
More information about jmjjg/cakephp3-database
Files in jmjjg/cakephp3-database
Package cakephp3-database
Short Description CakePHP 3 plugin that provides classes for adding default validation rules from the database table schema and cleaning data being saved.
License GPL-2.0+
Homepage https://github.com/jmjjg/cakephp3-database
Informations about the package cakephp3-database
Database
Description
CakePHP 3 plugin that provides classes for adding default validation rules from the database table schema and cleaning data being saved.
Caching is enabled by default but can be disabled in the configuration or at run-time.
Works well only with CakePHP 3.3.x (tested with CakePHP 3.3.12).
Main classes
AutovalidateBehavior reads various informations from the database table schema, such as column type, the fact that the column can be NULL, foreign key constraints, unique constraints and automatically adds those validation rules to the default ones.
FormattableBehavior cleans up data before validation or saving using configurable static class methods. The columns on which the formatters are applied can be defined based on column type and field name regular expression.
Setup
Assuming the plugin is installed under plugins/Database
, add the following to
config/bootstrap.php
:
Settings
The following global settings can optionally be added to the config/app.php
file.
Usage
The following code should be added to your table classes, inside the initialize() method.
The two behaviors are independant and can be loaded in any order.
Note that NULL and boolean TRUE and are equivalent as configuration values.