PHPackages                             tenga007/yii2-closure-table-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. tenga007/yii2-closure-table-behavior

ActiveYii2-extension

tenga007/yii2-closure-table-behavior
====================================

This extension allows you to get functional for closure table trees.

0.8.0(11y ago)05BSD-3-ClausePHPPHP &gt;=5.4.0

Since Jan 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/tenga007/yii2-closure-table-behavior)[ Packagist](https://packagist.org/packages/tenga007/yii2-closure-table-behavior)[ Docs](https://github.com/BioSin/yii2-closure-table-behavior)[ RSS](/packages/tenga007-yii2-closure-table-behavior/feed)WikiDiscussions master Synced 2mo ago

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

Closure table behavior for Yii2
===============================

[](#closure-table-behavior-for-yii2)

Yii2 port of the [yii-closure-table-behavior](https://github.com/AidasK/yii-closure-table-behavior). Extension allows managing trees stored in database via closure-table method.

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

[](#installation)

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

Either run

```
php composer.phar require valentinek/yii2-closure-table-behavior "*"
```

or add

```
"valentinek/yii2-closure-table-behavior": "*"
```

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

Configuring
-----------

[](#configuring)

First you need to configure model as follows:

```
class Category extends ActiveRecord
{
    public $leaf;

	public function behaviors() {
		return [
			[
				'class' => ClosureTable::className(),
				'tableName' => 'category_tree'
			],
		];
	}

	public static function find()
	{
		return new CategoryQuery(static::className());
	}
}
```

Second you need to configure query model as follows:

```
class CategoryQuery extends ActiveQuery
{
	public function behaviors() {
		return [
			[
				'class' => ClosureTableQuery::className(),
				'tableName' => 'category_tree'
			],
		];
	}
}
```

Migrations / Changing database schema
-------------------------------------

[](#migrations--changing-database-schema)

After configuring your model, you must copy migration file from behavior migrations folder to your project migrations folder. Please read the comments in file, change migration as you need and run migration:

```
php yii migrate
```

Also you change database schema directly using an example from .sql dump file in schema folder.

Road map
--------

[](#road-map)

```
1. Write documentation
2. Write tests
3. bug fixes
4. EVENT_DELETE
5. DeleteNode method refactoring
6. isAncestor() and isDescendant() methods

```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.3% 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

Unknown

Total

1

Last Release

4127d ago

### Community

Maintainers

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

---

Top Contributors

[![BioSin](https://avatars.githubusercontent.com/u/1442288?v=4)](https://github.com/BioSin "BioSin (21 commits)")[![tenga007](https://avatars.githubusercontent.com/u/5187412?v=4)](https://github.com/tenga007 "tenga007 (2 commits)")

---

Tags

yii2extensionBehaviorclosure table

### Embed Badge

![Health badge](/badges/tenga007-yii2-closure-table-behavior/health.svg)

```
[![Health](https://phpackages.com/badges/tenga007-yii2-closure-table-behavior/health.svg)](https://phpackages.com/packages/tenga007-yii2-closure-table-behavior)
```

###  Alternatives

[omgdef/yii2-multilingual-behavior

Port of the yii-multilingual-behavior for yii

143174.9k9](/packages/omgdef-yii2-multilingual-behavior)[valentinek/yii2-closure-table-behavior

This extension allows you to get functional for closure table trees.

1615.3k](/packages/valentinek-yii2-closure-table-behavior)[lav45/yii2-translated-behavior

This extension allows you to quickly and simple enough to add translations for any ActiveRecord models.

3742.2k](/packages/lav45-yii2-translated-behavior)[mdmsoft/yii2-autonumber

Auto number extension for the Yii framework

1830.9k](/packages/mdmsoft-yii2-autonumber)[v0lume/yii2-meta-tags

DB based model meta data for SEO

204.1k](/packages/v0lume-yii2-meta-tags)[liyunfang/yii2-upload-behavior

Upload behavior for Yii 2

161.7k](/packages/liyunfang-yii2-upload-behavior)

PHPackages © 2026

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