Eloq is a cute tool to validate & sanitize a form

v0.2.2 2015-06-17 07:34 UTC


Eloq is a PHP library to improve the security & the data validation of user forms.
It also improves code readability by separating the forms definition and treatment.

  1. Let's code
  2. How to Install
  3. How to Contribute
  4. Author & Community

Let's code

// Login form definition
$loginForm = (new Form)
    ->addInput('email', 'required|email|validate_email')
    ->addInput('password', 'required');

// Treatment
if ($loginForm->isValid()) {
    $email = $loginForm->email;
    $password = $loginForm->password;
    // Here we should log the user ;)
<?php if (!$loginForm->isValid('email')): ?>
	<div class="alert-error"><?= $loginForm->getInputErrorMessage('email') ?></div>
<?php endif; ?>
<input type="text" name="email" value="<?= $loginForm->email ?>" />

<?php if (!$loginForm->isValid('password')): ?>
	<div class="alert-error"><?= $loginForm->getInputErrorMessage('password') ?></div>
<?php endif; ?>
<input type="password" name="password" value="" />

↑ top

How to Install

If you don't have composer, you have to install it.

Add or complete the composer.json file at the root of your project, like this :

    "require": {
        "pixel418/eloq": "0.2.*"

Eloq can now be downloaded via composer.

Lastly, to use it in your PHP, you can load the composer autoloader :

require_once( './vendor/autoload.php' );

↑ top

How to Contribute

  1. Fork the Eloq repository
  2. Create a new branch for each feature or improvement
  3. Send a pull request from each feature branch to the develop branch

If you don't know much about pull request, you can read the Github article.

All pull requests must follow the PSR2 standard and be accompanied by passing phpunit tests.

↑ top

Author & Community

Eloq is under the MIT License. It is created and maintained by Thomas ZILLIOX.

↑ top