PHPackages                             jails/li3\_tree - 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. jails/li3\_tree

ActiveLithium-library[Framework](/categories/framework)

jails/li3\_tree
===============

Model tree behavior for the Lithium PHP framework

65493[1 issues](https://github.com/jails/li3_tree/issues)PHP

Since Jun 21Pushed 12y ago3 watchersCompare

[ Source](https://github.com/jails/li3_tree)[ Packagist](https://packagist.org/packages/jails/li3_tree)[ RSS](/packages/jails-li3-tree/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (0)

Tree behavior
=============

[](#tree-behavior)

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

[](#requirements)

- **PHP 5.4**
- This plugin needs [li3\_behaviors](https://github.com/jails/li3_behaviors).
- This plugin needs [li3\_fixtures](https://github.com/UnionOfRAD/li3_fixtures) (only if you intend to run tests).

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

[](#installation)

Checkout the code to either of your library directories:

```
cd libraries
git clone git@github.com:jails/li3_tree

```

Include the library in your `/app/config/bootstrap/libraries.php`

```
Libraries::add('li3_tree');

```

Presentation
------------

[](#presentation)

This behavior store hierarchical datas in a database table using the MPTT logic.

Constraints
-----------

[](#constraints)

To use the tree behavior, your table needs the following 3 extra fields:

- The `'parent'` config field. By default the field must be named `parent_id` in the table.
- The `'left'` config field. By default the field must be named `lft` in the table.
- The `'right'` config field. By default the field must be named `rght` in the table.

API
---

[](#api)

Example of attaching the tree behavior to a model:

```

```

### Options

[](#options)

In order to store multiple trees in the same table you need to set the `'scope'` option. For example, if a `Post` hasMany `Comment` and a `Comment` belongsTo a `Post`. To allow multiple `Comment` trees in the same table, you must scope `Comment` by the foreign key `post_id`. This way all `Comment` trees will be independant.

`'scope'` can be a full condition:

```
 protected $_actsAs = ['Tree' => ['scope' => ['region' => 'head']]];
```

Or a simple fieldname like a foreign key:

```
 protected $_actsAs = ['Tree' => ['scope' => ['post_id']]];
```

In this last case, the full condition will be populated from entity datas. This mean you can't do any CRUD action if the entity datas don't contain all necessary datas for perfoming a well scoped CRUD action.

### Example of use:

[](#example-of-use)

```

```

Greetings
---------

[](#greetings)

The li3 team, Vogan and all others which make that possible (I mean only because Chuck Norris agreed).

Build status
------------

[](#build-status)

[![Build Status](https://camo.githubusercontent.com/89de52bb827e6f6c3fb3773d41a773fd24bef857b07b529239f05eea33ff11c9/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6a61696c732f6c69335f747265652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/jails/li3_tree)

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1306941?v=4)[Simon JAILLET](/maintainers/jails)[@jails](https://github.com/jails)

---

Top Contributors

[![jails](https://avatars.githubusercontent.com/u/1306941?v=4)](https://github.com/jails "jails (18 commits)")[![djordje](https://avatars.githubusercontent.com/u/1223357?v=4)](https://github.com/djordje "djordje (9 commits)")

### Embed Badge

![Health badge](/badges/jails-li3-tree/health.svg)

```
[![Health](https://phpackages.com/badges/jails-li3-tree/health.svg)](https://phpackages.com/packages/jails-li3-tree)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M829](/packages/laravel-socialite)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k38.6M289](/packages/laravel-dusk)[pinguo/php-msf

Pinguo Micro Service Framework For PHP

1.7k4.2k](/packages/pinguo-php-msf)[nineinchnick/edatatables

Grid widget for the Yii Framework, wrapper for the DataTables jQuery plugin

173.2k](/packages/nineinchnick-edatatables)[link-cloud/fast-hyperf

LinkCloud Fast Hyperf

241.2k1](/packages/link-cloud-fast-hyperf)

PHPackages © 2026

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