Skip to content

zero12o/php-form

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Form

Lightweight form validation library for PHP, with a concise syntax and powerful use of closures.

Build Status

Basic example

// create the form with rules
$form = new Form([
    'name' => ['required', 'trim', 'max_length' => 255],
    'email' => ['required', 'email']
]);

if ( $form->validate($_POST) ) {
    // $_POST data is valid
    save_to_db_or_something($form->getValues());
}
else {
   // $_POST data is not valid
   display_errors_or_something($form->getErrors());
   // $form->getValues() can be used to repopulate the form
}

Complete doc is available in the wiki.

Requirements

Installation

The recommended way is to install the lib through Composer.

Just add this to your composer.json file:

{
    "require": {
        "rlanvin/php-form": "1.*"
    }
}

Then run composer install or composer update.

Now you can use the autoloader, and you will have access to the library:

<?php
require 'vendor/autoload.php';

Alternative method

  • Download the files in src/
  • (optional) Merge them into one
  • Put them in a folder that is autoloaded, or inclure or require them
  • Done

However be sure to come back regulary and check for updates.

Documentation

Complete doc is available in the wiki.

Contribution

Feel free to contribute! Just create a new issue or a new pull request.

License

This library is released under the MIT License.

About

Lightweight form validation library for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%