PHPackages                             rnr1721/le7-entify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. rnr1721/le7-entify

ActiveLibrary[Framework](/categories/framework)

rnr1721/le7-entify
==================

Entify is entity framework for le7 PHP MVC framework or any PHP project

1.1.5(3y ago)0732MITPHPPHP &gt;=8.1

Since May 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/rnr1721/le7-entify)[ Packagist](https://packagist.org/packages/rnr1721/le7-entify)[ RSS](/packages/rnr1721-le7-entify/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (16)Used By (2)

le7-entify
==========

[](#le7-entify)

Entify is entity framework for le7 PHP MVC framework or any PHP project

This project is a universal validator/converter. With it, it is possible to validate/normalize arrays. For example, you can use this project using the rules:

- Validate/render forms (and uploaded files)
- Validate/render arrays
- Validate/render data from the database

Requirements
------------

[](#requirements)

- PHP 8.1
- Composer

Installation
------------

[](#installation)

```
composer require rnr1721/le7-entify
```

Testing
-------

[](#testing)

```
composer test
```

Usage
-----

[](#usage)

1. Create rules in a class or array.
2. Create a DataProvider with Data
3. Get the entity
4. Get the verified entity

```
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' => 'required|minlength:3|maxlength:20'
	],
		'email' => [
			'label' => 'Email',
			'validate' => 'required|email'
	],
		'message' => [
			'label' => 'Message',
			'validate' => 'minlength:30|maxlength:200'
			'escape' => true
	],
		'age' => [
			'label' => 'Message',
			'convert' => 'int',
			'validate' => 'min:18|max:90'
	],
];

// Now get our data
$data = [
	'name' => 'John',
	'email' => 'johndoe@example.com',
	'message' => 'my message 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();
```

But it is basic usage. You can make more great things with Entify.

Rules in classes
----------------

[](#rules-in-classes)

For some reasons you may need to store rules in class, not in arrays. It great for storing rules for many-time usage from different places of your code. For example, we create file in namespaces Entities:

```
