pixel418 / eloq
Eloq is a cute tool to validate & sanitize a form
Requires
- php: >=5.4.0
- pixel418/ubiq: 0.4.*
This package is not auto-updated.
Last update: 2024-12-21 16:14:42 UTC
README
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.
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="" />
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' );
How to Contribute
- 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.
Author & Community
Eloq is under the MIT License. It is created and maintained by Thomas ZILLIOX.