PHPackages                             kak/behaviors - 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. kak/behaviors

ActiveLibrary[Framework](/categories/framework)

kak/behaviors
=============

behaviors collection for Yii2

v0.2(6y ago)01.4kMITPHP

Since Jul 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/sanchezzzhak/kak-behaviors)[ Packagist](https://packagist.org/packages/kak/behaviors)[ RSS](/packages/kak-behaviors/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Behavior collection for Yii2
============================

[](#behavior-collection-for-yii2)

ManyToManyBehavior (this project fork ) MaterializedPathBehavior (this project fork )

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

[](#installation)

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

Either run

```
php composer.phar require --prefer-dist kak/behavior "*"

```

or add

```
"kak/behavior": "*"

```

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

Usage ManyToManyBehavior
------------------------

[](#usage-manytomanybehavior)

```
```

\#MaterializedPathBehavior
--------------------------

[](#materializedpathbehavior)

insert the following code to your ActiveRecord class:

```
    use kak\models\behaviors\MaterializedPathBehavior

    // ...

    // step 1
     public function behaviors()
     {
         return [
            [
                'class' => MaterializedPathBehavior::class
            ],
         ];
     }
     // step 2
      /**
      * Query factory
      * @return MaterializedPathQuery
      */
     public static function find()
     {
         return new MaterializedPathQuery(get_called_class());
     }
```

Create class MaterializedPathQuery inherited from ActiveQuery

```
/**
Class MaterializedPathQuery
 * @return bool
 */
class MaterializedPathQuery extends ActiveQuery
{
    /**
     * Get root nodes
     * @return MaterializedPathModel
     */
    public function getChildren($path)
    {
        /** @var ActiveQuery $this */
        $this->andWhere(['path' => '.'.$path.'%']);
        return $this;
    }
}
```

Set materialized path

```
    $categoryModel = new Category(['parent_id' => 123 ]);
    $categoryModel->save();
```

\#SluggableBehavior
-------------------

[](#sluggablebehavior)

insert the following code to your ActiveRecord class:

```
use kak\models\behaviors\SluggableBehavior;

     public function behaviors()
     {
         return [
            [
                 'class' => SluggableBehavior::class,
                 'attribute' => 'title',
                 'slugAttribute' => 'slug',
                 // 'replacements' => [ '_' => '-']
                 // 'limit' => '100'                  // truncate text
                 // 'delimiter' => '-'                // default delimiter
             ]
         ];
     }
```

\#CallbackBehavior
------------------

[](#callbackbehavior)

insert the following code to your ActiveRecord class:

```
use kak\models\behaviors\CallbackBehavior;

// ...

    public function behaviors()
    {
        return [
            'class' => CallbackBehavior::class,
            'params' => [
                'operators' => [
                    'attribute' => 'operator_list',
                    // implode/explode method
                    'method' => CallbackBehavior::METHOD_STRING,
                    'delimiter' => '|', // set other  delimiter only METHOD_STRING
                    // or json_encode/json_decode method
                    'method' => CallbackBehavior::METHOD_JSON,
                    // or custom callback
                    'set' => function ($value) {
                        return implode(',', $value);
                    },
                    'get' => function ($value) {
                        return explode(',', $value);
                    },
                ],
            ],
        ];
    }
```

\#UUIDBehavior
--------------

[](#uuidbehavior)

- is use postgress set actived module `uuid-ossp`
- `create extension if not exists "uuid-ossp"`

insert the following code to your ActiveRecord class:

```
use kak\models\behaviors\UUIDBehavior;

// ...

 public function behaviors()
 {
     return [
         [
             'class' => UUIDBehavior::class,
             'createViaDb' => true   // is use postgress
         ],
      ;
  }
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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 ~1756 days

Total

2

Last Release

2242d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f0a9b5d532bda5e53a2a5707151ac365e365a04fa7f3fc3a26f2289f9c277082?d=identicon)[sanchezzzhak](/maintainers/sanchezzzhak)

---

Top Contributors

[![sanchezzzhak](https://avatars.githubusercontent.com/u/1337066?v=4)](https://github.com/sanchezzzhak "sanchezzzhak (11 commits)")

---

Tags

yii2behaviors yii2kak behaviorsManyToManyBehaviorMaterializedPathBehavior

### Embed Badge

![Health badge](/badges/kak-behaviors/health.svg)

```
[![Health](https://phpackages.com/badges/kak-behaviors/health.svg)](https://phpackages.com/packages/kak-behaviors)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[yiisoft/yii2-redis

Redis Cache, Session and ActiveRecord for the Yii framework

47912.3M279](/packages/yiisoft-yii2-redis)[yiisoft/yii2-app-advanced

Yii 2 Advanced Project Template

1.7k961.7k5](/packages/yiisoft-yii2-app-advanced)[yiisoft/yii2-httpclient

HTTP client extension for the Yii framework

44411.6M327](/packages/yiisoft-yii2-httpclient)[yiisoft/yii2-debug

The debugger extension for the Yii framework

21624.5M620](/packages/yiisoft-yii2-debug)[yiisoft/yii2-app-basic

Yii 2 Basic Project Template

7101.8M8](/packages/yiisoft-yii2-app-basic)

PHPackages © 2026

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