PHPackages                             plook/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. plook/tree

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

plook/tree
==========

Library for working with tree data structures.

0.5.0(2y ago)02[4 PRs](https://github.com/pl-github/php-tree/pulls)LGPL-2.1-or-laterPHPPHP ^8.2CI passing

Since Feb 16Pushed 2w ago1 watchersCompare

[ Source](https://github.com/pl-github/php-tree)[ Packagist](https://packagist.org/packages/plook/tree)[ RSS](/packages/plook-tree/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (9)Versions (10)Used By (0)

Tree
====

[](#tree)

[![codecov](https://camo.githubusercontent.com/93f550a878cf2061e7f694989e53fc3cbc9ee441276d5877ada99366bf5e6729/68747470733a2f2f636f6465636f762e696f2f67682f706c2d6769746875622f7068702d747265652f67726170682f62616467652e7376673f746f6b656e3d3743595136544f35474a)](https://codecov.io/gh/pl-github/php-tree)

A PHP library for working with tree data structures.

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

[](#installation)

```
$ composer require plook/tree
```

Working with trees that are stored in arrays
--------------------------------------------

[](#working-with-trees-that-are-stored-in-arrays)

### Traversing a left/right tree that is ordered by the left value

[](#traversing-a-leftright-tree-that-is-ordered-by-the-left-value)

```
$tree = [
    ['id' => 1, 'left' => 1, 'right' => 14],
    ['id' => 2, 'left' => 2, 'right' => 7],
    ['id' => 3, 'left' => 3, 'right' => 4],
    ['id' => 4, 'left' => 5, 'right' => 6],
    ['id' => 5, 'left' => 8, 'right' => 13],
    ['id' => 6, 'left' => 9, 'right' => 10],
    ['id' => 7, 'left' => 11, 'right' => 12],
];

/** @var TraverseLeftRightTree $traverse */
$traverse = new TraverseLeftRightTree();

$traverse(
    $tree,
    'left',
    'right',
    static function (array $node): void {
        echo sprintf('Processing node %s%s', $node['id'], PHP_EOL);
    },
    static function (array $node): void {
        echo sprintf('Childrens of node %s have been processed%s', $node['id'], PHP_EOL);
    },
);
```

```
Processing node 1
Processing node 2
Processing node 3
Childrens of node 3 have been processed
Processing node 4
Childrens of node 4 have been processed
Childrens of node 2 have been processed
Processing node 5
Processing node 6
Childrens of node 6 have been processed
Processing node 7
Childrens of node 7 have been processed
Childrens of node 5 have been processed
Childrens of node 1 have been processed

```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance63

Regular maintenance activity

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

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

868d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/af5decb62b44eeee60d94d96c0bb22bc160aff4754e5ea1c332789efcd1183e2?d=identicon)[pl-github](/maintainers/pl-github)

---

Top Contributors

[![pl-github](https://avatars.githubusercontent.com/u/1941578?v=4)](https://github.com/pl-github "pl-github (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

PHPackages © 2026

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