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.
// 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="" />
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' );
- Fork the Eloq repository
- Create a new branch for each feature or improvement
- 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.
Eloq is under the MIT License. It is created and maintained by Thomas ZILLIOX.