1. Go to this page and download the library: Download rnr1721/le7-entify library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rnr1721 / le7-entify example snippets
use Core\Entify\RulesLoaderClass;
use Core\Entify\Entification;
// Loader for rules
$loader = new RulesLoaderClass();
// Get Entify factory. We can create $loader and $entifications in container
$entification = new Entification($loader);
// Make our rules. In this example is array,
// But more comfortable use classes
$rulesArray = [
'name' => [
'label' => 'User login',
'validate' => 'essage text',
'age' => '33'
];
$provider = $entification->getArrayProvider($data, $rulesArray);
// Get entity
$entity = $provider->getEntity();
// our validated and normalized array
print_r($entity->export())
// Get validation errors if present
$entity->getErrors();
use Core\Entify\RulesLoaderClass;
use Core\Entify\Entification;
// Loader for rules. Warning! Now we set namespace with entities rules!
$loader = new RulesLoaderClass('\\Entities\\');
// Get Entify factory
$entification = new Entification($loader);
// Now get our data
$data = [
'name' => 'John',
'email' => '[email protected]',
'message' => 'my message text',
'age' => '33'
];
// Contatform - is class with rules. Now we can set it here
// Starts with lowercase
$provider = $entification->getArrayProvider($data, 'contactform');
// Get entity
$entity = $provider->getEntity();
// our validated and normalized array
print_r($entity->export())
// Get validation errors if present
$entity->getErrors();
use Core\Entify\RulesLoaderClass;
use Core\Entify\Entification;
// Loader for rules. Warning! Now we set namespace with entities rules!
$loader = new RulesLoaderClass('\\Entities\\');
// Get Entify factory
$entification = new Entification($loader);
// Now get our data
$data = [
'name' => 'John',
'email' => '[email protected]',
'message' => 'my message text',
'age' => '33'
];
// Contatform - is class with rules. Now we can set it here
// Starts with lowercase
$provider = $entification->getArrayProvider($data, 'contactform');
// If this, the fields that not present in rules, will be deleted
// Default is true;
$provider->getOptions()->setDeleteRedundant(true);
// Skip validation (only skip validator)
// Default is false
$provider->getOptions()->setSkipValidation(true);
// If validator got errors, any filters will not be applied
// Default false
$provider->getOptions()->setReturnIfValidationErrors(true);
// If some field of array not present in rules, return before filters and validation
// Default false
$provider->getOptions()->setReturnIfNotExistsErrors(true);
// Get entity
$entity = $provider->getEntity();
// our validated and normalized array
print_r($entity->export())
// Get validation errors if present
$entity->getErrors();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.