Skip to content
devsmoPublic

About

Copy of an old rlanvin lib, updated to supprt php 8.x

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

PHP Form

Lightweight form validation library for PHP, with a concise syntax and powerful use of closures. It can validate traditional form submissions as well as API requests.

Build Status Latest Stable Version

Credit

This repo is a copy of rlanvin/php-form It's puodated to support PHP 8.x

Basic example

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

if ( $form->validate($_POST) ) {
    // $_POST data is valid
    $form->getValues(); // returns an array of sanitized values
}
else {
   // $_POST data is not valid
   $form->getErrors(); // contains the errors
   $form->getValues(); // can be used to repopulate the form
}

Complete doc is available in the wiki.

Requirements

If you are stuck with PHP 5.3, you may still use version 1.1.

Installation

The recommended way is to install the lib through Composer.

Just add this to your composer.json file:

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

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 (not recommended)

  • Download the latest release
  • Put the files in a folder that is autoloaded, or inclure or require them

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

Copy of an old rlanvin lib, updated to supprt php 8.x

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages