PHPackages                             alekciy/yii2-save-autorelations-behavior - 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. [Database &amp; ORM](/categories/database)
4. /
5. alekciy/yii2-save-autorelations-behavior

ActiveYii2-extension[Database &amp; ORM](/categories/database)

alekciy/yii2-save-autorelations-behavior
========================================

Auto create relations, validate and save automatically related Active Record models.

0.1.1(6y ago)01[1 PRs](https://github.com/alekciy/yii2-save-autorelations-behavior/pulls)MITPHP

Since Feb 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/alekciy/yii2-save-autorelations-behavior)[ Packagist](https://packagist.org/packages/alekciy/yii2-save-autorelations-behavior)[ RSS](/packages/alekciy-yii2-save-autorelations-behavior/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

Yii2 Active Record Save Auto Relations Behavior
===============================================

[](#yii2-active-record-save-auto-relations-behavior)

Данное поведение расширяет [yii2-save-relations-behavior](https://packagist.org/packages/la-haute-societe/yii2-save-relations-behavior)автоматически создавая связи на основании заданной конфигурации.

Установка
---------

[](#установка)

Через [composer](http://getcomposer.org/download/):

```
composer require --prefer-dist alekciy/yii2-save-autorelations-behavior

```

Конфигурирование
----------------

[](#конфигурирование)

В модель нужно лишь дописать связанную с ней другую модель. Для связи 1-n в свойство `manyRelationList`, для 1-1 в `oneRelationList`. Например, нужно добавить в класс машины `Car` связь с водителями `Driver`:

```
use yii\db\ActiveRecord;
use alekciy\Yii2SaveAutoRelationsTrait;
use alekciy\Yii2SaveAutoRelationsBehavior;

class Car extends ActiveRecord
{
    use Yii2SaveAutoRelationsTrait; // Необязательно, но нужно для загрузки связи через loadRelations()

    public function behaviors()
    {
        return [
            'saveRelations' => [
                'class' => Yii2SaveAutoRelationsBehavior::className(),
                'manyRelationList' => [
                    'drivers' => Driver::class,
                ],
            ],
        ];
    }
}
```

Вот и все. Не нужно создавать `getDrivers()` метод. Поведение автоматически создаст таблицу связей (имя начинается с префикса `link__`). С остальными вариантами использования можно ознакомиться на странице [Yii2 Active Record Save Relations Behavior](https://github.com/la-haute-societe/yii2-save-relations-behavior#usage)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~0 days

Total

2

Last Release

2283d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/427741?v=4)[Сундуков Алексей](/maintainers/alekciy)[@alekciy](https://github.com/alekciy)

---

Top Contributors

[![alekciy](https://avatars.githubusercontent.com/u/427741?v=4)](https://github.com/alekciy "alekciy (3 commits)")

---

Tags

databaseyii2extensionBehavioractive-recordrelationshas\_onehas-manyactive-queryauto-relation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alekciy-yii2-save-autorelations-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/alekciy-yii2-save-autorelations-behavior/health.svg)](https://phpackages.com/packages/alekciy-yii2-save-autorelations-behavior)
```

###  Alternatives

[voskobovich/yii2-linker-behavior

This behavior makes it easy to maintain many-to-many and one-to-many relations in your ActiveRecord models.

80319.0k9](/packages/voskobovich-yii2-linker-behavior)[johnitvn/yii2-ajaxcrud

Gii CRUD template for Single Page Ajax Administration for yii2

97209.6k16](/packages/johnitvn-yii2-ajaxcrud)[dmstr/yii2-db

Database extensions

19618.8k6](/packages/dmstr-yii2-db)[mg-code/yii2-helpers

A collection of useful helper classes for Yii framework 2.0

2022.5k5](/packages/mg-code-yii2-helpers)

PHPackages © 2026

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