PHPackages                             odannyc/treeize - 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. odannyc/treeize

ActiveLibrary

odannyc/treeize
===============

The ultimate tree library. For all your tree recursion needs.

v1.2.2(9y ago)14211Apache-2.0PHP

Since Dec 5Pushed 9y ago1 watchersCompare

[ Source](https://github.com/odannyc/Treeize)[ Packagist](https://packagist.org/packages/odannyc/treeize)[ RSS](/packages/odannyc-treeize/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (8)DependenciesVersions (9)Used By (0)

Treeize
=======

[](#treeize)

The ultimate tree library. For all your tree recursion needs.

```
Treeize::create($tree)->parse()->get();
```

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

[](#installation)

You can install this library using [composer](https://getcomposer.org/download/)

`composer require odannyc/treeize`

Usage
-----

[](#usage)

Given a simple array:

```
$tree = [
  [
    "id" => 1,
    "parent_id" => 0
  ],
  [
    "id" => 2,
    "parent_id" => 1
  ],
  [
    "id" => 3,
    "parent_id" => 1
  ],
  [
    "id" => 4,
    "parent_id" => 2
  ],
  [
    "id" => 5,
    "parent_id" => 2
  ],[
    "id" => 6,
    "parent_id" => 0
  ],
  [
    "id" => 7,
    "parent_id" => 6
  ],
  [
    "id" => 8,
    "parent_id" => 6
  ]
]
```

You will be able to parse this tree and set it correctly recursively doing this:

```
Treeize::create($tree)->parse()->get();
```

The output will be:

```
[
  [
    "id" => 1,
    "parent_id" => 0,
    "children" => [
      [
        "id" => 2,
        "parent_id" => 1,
        "children" => [
          [
            "id" => 4,
            "parent_id" => 2
          ],
          [
            "id" => 5,
            "parent_id" => 2
          ]
        ]
      ],
      [
        "id" => 3,
        "parent_id" => 1
      ],
    ]
  ],
  [
    "id" => 6,
    "parent_id" => 0,
    "children" => [
      [
        "id" => 7,
        "parent_id" => 6
      ],
      [
        "id" => 8,
        "parent_id" => 6
      ]
    ]
  ]
]
```

If you'd like to change the "children" key to any other string you can do so by chaining off the `create` method before parsing. So:

```
Treeize::create($tree)->childrenKey('nodes')->parse()->get();
```

There's other options to chain on that method, here's the whole list:

```
Treeize::create($tree)
  ->parentKey('pid')
  ->indexKey('id')
  ->parentId(0)
  ->childrenKey('nodes')
  ->parse(function($item) {//do stuff to item})
  ->get();
```

`parentKey`

- Sets the parent key name: Default is "parent\_key"

`indexKey`

- Sets the index key name: Default is "id"

`parentId`

- Sets the initial parent ID to search for: This is figured out if non is provided

`childrenKey`

- Sets the children key name as described above.

`parse`

- Accepts a callback function that you can apply to each item in the tree, an item is an array in this instance.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity68

Established project with proven stability

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

Total

8

Last Release

3437d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4f6ee318ea05028b3108314667fd5a0f60a0fe76eeb752031bbb478eaf1ba739?d=identicon)[odannyc](/maintainers/odannyc)

---

Top Contributors

[![odannyc](https://avatars.githubusercontent.com/u/12864641?v=4)](https://github.com/odannyc "odannyc (17 commits)")

### Embed Badge

![Health badge](/badges/odannyc-treeize/health.svg)

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

PHPackages © 2026

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