PHPackages                             ovidiupop/yii2-identities - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ovidiupop/yii2-identities

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

ovidiupop/yii2-identities
=========================

The "identities" module is designed to manage and manipulate information related to identities, which can be either individuals or companies. It provides functionalities such as handling data associated with these entities, displaying, and manipulating them.

062PHP

Since Jan 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ovidiupop/yii2-identities)[ Packagist](https://packagist.org/packages/ovidiupop/yii2-identities)[ RSS](/packages/ovidiupop-yii2-identities/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

The "identities" module is designed for managing and manipulating information related to both individuals and companies. It provides functionalities for handling associated data, displaying, and performing manipulations.

**Installation**

The recommended installation method is using Composer.

```
composer require --prefer-dist ovidiupop/yii2-identities "@dev"

```

Or, add the following line to your composer.json file:

```
"ovidiupop\yii2-identities": "@dev"

```

**Configuration**

Run the migration located in the migrations folder to create the necessary tables.

In the config/main.php file, add:

```
'modules' => [
    'identities' => [
        'class' => 'ovidiupop\identities\IdentitiesModule',
    ],
],

```

**Usage**

To manage all entities on a single page without customization, visit /identities/identity/index. Here, you can add, update, and delete both individual and company identities.

**Customization**

The module utilizes standard Yii2 components (GridView and DetailView), and the design follows the default styling.

For customization, the following configurations are available:

Example for full customization:

```
'modules' => [
    'identities' => [
        'class' => 'ovidiupop\identities\IdentitiesModule',
        'addressFormCustom' => '@backend/identities_custom/custom_address_form',
        'form' => '@backend/identities_custom/_form_identity',
        'formPersonCompany' => '@backend/identities_custom/form_person_company',
        'view' => '@backend/identities_custom/view_identity',
        'index' => '@backend/identities_custom/index_identity',
        --------------------- .php is required ----------------
        'columns' => '@backend/identities_custom/columns.php',
        'gridConfig' => '@backend/identities_custom/grid_config.php',
        'gridConfigPersons' => '@backend/identities_custom/grid_config_persons.php',
        'gridConfigCompanies' => '@backend/identities_custom/grid_config_companies.php',
        ]
    ..................

```

Of course, all paths are just examples, but you can use any paths for your custom files.
To begin customization, copy the module's files (or from customized folder) to your project folder and then personalize them as needed.

***Customization details:***

```
addressFormCustom - the file where the address data collection form is configured.
form - the file for creating and updating new identities.
formPersonCompany - the file for customizing forms for persons and companies.
view - the view file.
index - the index file for accessing the grid of registered identities.
columns - if using custom grids (e.g., kartik/Grid), prepare the grid columns accordingly.
gridConfig - the file where the order and visibility of grid columns are set.
gridConfigPersons - when displaying only entities of type Person, set the order and visibility of grid columns.
gridConfigCompanies - when displaying only entities of type Company, set the order and visibility of grid columns.

```

In the index\_identity.php file, obtain the columns for the grid as follows:

```
// For all columns
$columns = Yii::$app->getModule('identities')->getColumnsForGrid($searchModel, $dataProvider);

// For separate entities in the index, add an extra parameter "$columnsForType" received from the controller.
$columns = Yii::$app->getModule('identities')->getColumnsForGrid($searchModel, $dataProvider, $columnsForType);

```

To manage specialized identities separately, create a controller for each type (persons and companies) in your project. Controllers should use the IdentitiesTrait. A complete controller should look like this:

```
