PHPackages                             kasoft/yii2-jstree - 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. kasoft/yii2-jstree

Abandoned → [https://github.com/studio255/yii2-jstree/releases](/?search=https%3A%2F%2Fgithub.com%2Fstudio255%2Fyii2-jstree%2Freleases)Yii2-extension[Utility &amp; Helpers](/categories/utility)

kasoft/yii2-jstree
==================

Yii2 widget wrapping the jsTree jQuery library — displays and manages ActiveRecord models as interactive trees.

v1.0.18(4w ago)460.0k↓52.6%3MITPHPPHP &gt;=8.2CI passing

Since Dec 6Pushed 4w agoCompare

[ Source](https://github.com/studio255/yii2-jstree)[ Packagist](https://packagist.org/packages/kasoft/yii2-jstree)[ Docs](https://github.com/studio255/yii2-jstree)[ RSS](/packages/kasoft-yii2-jstree/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (4)Versions (20)Used By (0)

yii2-jstree
===========

[](#yii2-jstree)

[![Latest Version](https://camo.githubusercontent.com/6fde5ee4fcb9b8b835ffa6b262353276e2d174a035eeb7c3eb29277e013dc389/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73747564696f3235352f796969322d6a73747265652e737667)](https://packagist.org/packages/studio255/yii2-jstree)[![Total Downloads](https://camo.githubusercontent.com/a0a680b5a9ba9d8fd77b35f69f579396014ee5f43c9be8071af9e30cd5ad1d67/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73747564696f3235352f796969322d6a73747265652e737667)](https://packagist.org/packages/studio255/yii2-jstree)[![License](https://camo.githubusercontent.com/bd2c04d6252c84269c2ff98582d65421c714dc702ae4ae999a8db95bbe04a6f5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f73747564696f3235352f796969322d6a73747265652e737667)](LICENSE)

A Yii2 widget for the [jsTree](https://www.jstree.com/) jQuery library — display and manage Yii2 ActiveRecord models as interactive trees.

[![screenshot.png](docs/screenshot.png)](docs/screenshot.png)

Features
--------

[](#features)

- Load tree data via AJAX
- Custom icons per node type (FontAwesome, Bootstrap Icons, or any CSS class)
- Context menu: create, rename, duplicate, delete
- Drag-and-drop reordering
- Submenu with individual node types
- Dynamic context menu — hide items per node type (e.g. no *delete* on type *page*)
- Customizable labels and confirmation messages
- Yii2 validation errors forwarded to JavaScript alerts

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Yii2 2.0.51 or higher

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

[](#installation)

```
composer require studio255/yii2-jstree
```

Usage
-----

[](#usage)

### Simple variant — JSON URL only

[](#simple-variant--json-url-only)

```
$tree = new \studio255\jstree\JsTree([
    'jsonUrl' => '/my-json-url/data',
]);
```

```

```

### Full variant — backed by a Yii2 ActiveRecord model

[](#full-variant--backed-by-a-yii2-activerecord-model)

Enables create, move, rename and delete operations on the model directly from the tree.

**Required model / database fields:**

FieldRequiredPurpose`name`yesDisplay label`parent_id`yesTree nesting`position`yesSort order within parent`type`noUsed for icon and permission handling> **Important:** Only `name` should be a required attribute in your model — otherwise the *New* context menu action may fail.

**Controller setup:**

```
public function actionIndex()
{
    $tree = new \studio255\jstree\JsTree([
        'modelName'             => 'backend\\models\\YourModel',
        'modelPropertyId'       => 'id',
        'modelPropertyParentId' => 'parent_id',
        'modelPropertyPosition' => 'position',
        'modelPropertyName'     => 'name',
        'modelFirstParentId'    => null,
        'modelPropertyType'     => 'type',
        'controllerId'          => 'index',
        'jstreeDiv'             => '#jstree',
        'jstreeIcons'           => false,
        'jstreePlugins'         => ['contextmenu', 'dnd'],
        'jstreeContextMenue'    => [
            'remove' => ['text' => 'Delete', 'icon' => 'fa fa-trash'],
            'edit'   => ['text' => 'Edit',   'icon' => 'fa fa-pencil'],
            'create' => [
                'text'    => 'Create new',
                'icon'    => 'fa fa-plus',
                'type'    => 'online',
                'submenu' => [
                    ['text' => 'New offline node', 'icon' => 'fa fa-cloud',      'type' => 'offline'],
                    ['text' => 'New online node',  'icon' => 'fa fa-cloud-bolt', 'type' => 'online'],
                ],
            ],
            'rename' => ['text' => 'Rename', 'icon' => 'fa fa-i-cursor'],
        ],
        'jstreeType' => [
            '#'       => ['max_children' => -1, 'max_depth' => -1, 'valid_children' => -1, 'icon' => 'fa fa-list'],
            'default' => ['icon' => 'fa fa-question'],
        ],
        'jstreeMsg' => [
            'confirmdelete' => 'Are you sure you want to delete this item?',
            'nothere'       => 'Not allowed at this position.',
        ],
    ]);

    return $this->render('index');
}
```

**View setup:**

A click on a tree item triggers the update action via AJAX and loads the result into `.jstree-result`. Forms used inside the result div should carry the class `jstree-form` so their submit response is routed back to the result container.

```

```

The icon classes in the examples use FontAwesome — any CSS-based icon set works (Bootstrap Icons, Material, custom classes).

Demo
----

[](#demo)

A working demo setup is available in the [`demo/`](demo/) directory.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance94

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~423 days

Total

19

Last Release

28d ago

PHP version history (2 changes)v1.0.14PHP &gt;=7.2

v1.0.17PHP &gt;=8.2

### Community

Maintainers

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

---

Top Contributors

[![studio255](https://avatars.githubusercontent.com/u/3940053?v=4)](https://github.com/studio255 "studio255 (102 commits)")[![kasoft](https://avatars.githubusercontent.com/u/3940053?v=4)](https://github.com/kasoft "kasoft (101 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![amunozg](https://avatars.githubusercontent.com/u/14159009?v=4)](https://github.com/amunozg "amunozg (1 commits)")

---

Tags

jstreephptreewidgetyii2yii2-extensionuitreeyii2widgetyii2-extensiontreeviewjstree

### Embed Badge

![Health badge](/badges/kasoft-yii2-jstree/health.svg)

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

###  Alternatives

[devgroup/yii2-jstree-widget

jsTree widget for yii2

2323.7k](/packages/devgroup-yii2-jstree-widget)[thiagotalma/yii2-jstree

Widget for Yii Framework 2.0 to use JsTree

3263.8k2](/packages/thiagotalma-yii2-jstree)[yii-dream-team/yii2-jstree

Yii2 JsTree assets and widget

3151.0k](/packages/yii-dream-team-yii2-jstree)[drsdre/yii2-wizardwidget

Multi step wizard widget using tabs to guide a user through steps to complete a task. Based on the Form wizard (using tabs) from lukepzak (see http://bootsnipp.com/snippets/featured/form-wizard-using-tabs).

41149.5k](/packages/drsdre-yii2-wizardwidget)

PHPackages © 2026

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