PHPackages                             shintio/yii2-profile - 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. shintio/yii2-profile

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

shintio/yii2-profile
====================

CRUD additional attributes without writing code.

0.1(8y ago)642GPL-3.0+PHP

Since Nov 9Pushed 8y ago3 watchersCompare

[ Source](https://github.com/Shintio/yii2-profile)[ Packagist](https://packagist.org/packages/shintio/yii2-profile)[ RSS](/packages/shintio-yii2-profile/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (2)Used By (0)

Profile with additional attributes for ActiveRecord
===================================================

[](#profile-with-additional-attributes-for-activerecord)

Create, update, delete additional attributes of model without change model code.

Это руководство также доступно [на русском языке](./README.ru.md).

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require shintio/yii2-profile "*"

```

or add

```
"shintio/yii2-profile": "*"

```

to the require section of your `composer.json` file.

Before start
------------

[](#before-start)

Before start you should create tables in your db. You can find SQL query in the end of this file. After create tables you should create or generate with gii ActiveRecord models for these tables.

Usage
-----

[](#usage)

For adding additional fields you should insert row to table '*enitity\_profile\_field*'.

- **code**- string on which you can use this field.
- **name**- string, Human-Understandable name of this field. Use this for display field name to users.
- **type**- json, type of this field. This version only supports *`{"type":"text"}`*. More types in future updates.

namespace:

```
use shintio\profile\Profile;
```

Create Profile object and ActiveRecord model by class name:

```
// User- ActiveRecord model
$profile=new Profile(User::className());
```

Create Profile object by existing ActiveRecord:

```
// We can create new User;
$user=new User();
// Also we can use existing User;
//$user=User::find()->one();

$profile=new Profile($user);
```

Find Profile:

```
$query=Profile::find(User::className());

// In where function we can use:
// Assoc array for '=' condition
$query->where(['username'=>'admin']); // username- User's attribute
// Indexed array for '%LIKE%' condition
$query->andWhere(['LIKE','firstName','Adm']); // firstName- additional profile field
$query->orWhere(['lastName'=>'Great']); // lastName- additional profile field

$profile=$query->one();
//$profiles=$query->all();
```

Work with fields:

```
echo $profile->getField('firstName'); // Admin

$profile->setField('firstName','Moder');
echo $profile->getField('firstName'); // Moder

$profile->setField('username','moder');

echo '';
// Get profile in array of Field ojbects
var_dump($profile->getProfile());
// Get profile in assoc array
// var_dump($profile->getProfile(true));
// Same as getProfile(true)
// var_dump($profile->getProfileInArray());
echo '';

$profile->save();
// username: moder
// firstName: Moder
// lastName: Great
```

SQL for generate example tables you can find in file **example.sql**Also you can you this template for create table for any entities. Before executing this query replace all '*entity*' to your entity name.

```
CREATE TABLE `entity` (
  `id` int(11) NOT NULL,
  `name` varchar(255) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `entity_profile` (
  `id` int(11) NOT NULL,
  `entity_id` int(11) NOT NULL,
  `field_id` int(11) NOT NULL,
  `value` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `entity_profile_field` (
  `id` int(11) NOT NULL,
  `code` varchar(255) NOT NULL,
  `name` varchar(255) NOT NULL,
  `type` json NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `entity`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `entity_profile`
  ADD PRIMARY KEY (`id`),
  ADD KEY `entity_id` (`entity_id`),
  ADD KEY `field_id` (`field_id`);

ALTER TABLE `entity_profile_field`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `entity_profile`
  ADD CONSTRAINT `entity_profile_ibfk_1` FOREIGN KEY (`field_id`) REFERENCES `entity_profile_field` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `entity_profile_ibfk_2` FOREIGN KEY (`entity_id`) REFERENCES `entity` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3107d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/05b148fe3b05786a799d85838ae804eb0e1e00f6f5bfe3d0d49bee558a5f3ff5?d=identicon)[AlekseyTopor](/maintainers/AlekseyTopor)

---

Tags

activerecordadditionaladditional-attributesattributescustomcustom-fieldsexpandable-modelfieldsprofileyiiyii2yii2extension

### Embed Badge

![Health badge](/badges/shintio-yii2-profile/health.svg)

```
[![Health](https://phpackages.com/badges/shintio-yii2-profile/health.svg)](https://phpackages.com/packages/shintio-yii2-profile)
```

###  Alternatives

[vyants/yii2-daemon

Extension provides functionality for simple daemons creation and control

7859.0k](/packages/vyants-yii2-daemon)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
