PHPackages                             codrasil/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. codrasil/tree

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

codrasil/tree
=============

PHP Library to generate a hierarchical tree list from array.

v1.0.2(6y ago)0839MITPHPPHP &gt;=7.1

Since Feb 18Pushed 6y ago1 watchersCompare

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

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

Codrasil / Tree
===============

[](#codrasil--tree)

[![Latest Stable Version](https://camo.githubusercontent.com/78d1d53ae5e2aedff95837891119e1c1232f2562cc428ebc9ff70663ca43b546/68747470733a2f2f706f7365722e707567782e6f72672f636f64726173696c2f747265652f762f737461626c65)](https://packagist.org/packages/codrasil/tree)[![Total Downloads](https://camo.githubusercontent.com/9a4c653f68215afbe23fa216f116aeb0f80416526f34b37ebd4045213b0e81e4/68747470733a2f2f706f7365722e707567782e6f72672f636f64726173696c2f747265652f646f776e6c6f616473)](https://packagist.org/packages/codrasil/tree)[![Latest Unstable Version](https://camo.githubusercontent.com/1275e3f40f47e7a3ce8dbc92ff3c347504164089bd46ab970f64b1ddd2bb3930/68747470733a2f2f706f7365722e707567782e6f72672f636f64726173696c2f747265652f762f756e737461626c65)](https://packagist.org/packages/codrasil/tree)[![License](https://camo.githubusercontent.com/a5d19b204ce7ab2306bbefab813274962e55856ed07596372f80a1acdc49a1de/68747470733a2f2f706f7365722e707567782e6f72672f636f64726173696c2f747265652f6c6963656e7365)](https://packagist.org/packages/codrasil/tree)

PHP Library to generate a hierarchical tree list from array. Ideal for creating menus, sidebars, and any nested resources.

#### Requirements

[](#requirements)

- **php**: `>=7.1`

#### Installation

[](#installation)

```
$ composer require codrasil/tree
```

```
{
    "require": {
        "codrasil/tree": "^1.*"
    }
}
```

#### Usage

[](#usage)

```
use Codrasil\Tree\Tree;

$menus = [
  ['id' => 'menu:user', 'text' => 'Users', 'order' => 2, 'children' => [ ... ]],
  ['id' => 'menu:blog', 'text' => 'Blogs', 'order' => 1],
  ['id' => 'submenu:blog:category', 'parent' => 'menu:blog', 'text' => 'Blog Categories', 'order' => 1],
];

$options = [
  'key' => 'id',
  'parent' => 'parent',
  'children' => 'children',
];

$tree = new Tree($menus, $options);

$tree->build();

print_r($tree->get());
/*
output:

Array
(
    [menu:blog] => Codrasil\Tree\Branch Object
        (
            [key:protected] => menu:blog
            [parent:protected] => root
            [node:protected] => Array
                (
                    [name] => menu:blog
                    [parent] => root
                    [order] => 1
                    [children] => Array
                        (
                            [submenu:blog:category] => Codrasil\Tree\Branch Object
                                (
                                    ...
                                )
                        )
                    [left] => 2
                    [right] => 3
                )
        )
    [menu:user] => Codrasil\Tree\Branch Object ( ... )
*/
```

You may also run the demo inside the tests folder via cloning this repository, then starting a php server on the `tests/` folder.

```
cd /path/to/codrasil/tree
php -S localhost:8080 -t tests/
```

[![Screenshot of demo server](./screenshot.demo.tests.png)](./screenshot.demo.tests.png)

#### Documentation

[](#documentation)

coming soon

#### License

[](#license)

The Codrasil/Tree PHP library is open-source software licensed under the [MIT license](./LICENSE).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

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

Total

3

Last Release

2535d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15792724?v=4)[John Lioneil Dionisio](/maintainers/lioneil)[@lioneil](https://github.com/lioneil)

---

Top Contributors

[![lioneil](https://avatars.githubusercontent.com/u/15792724?v=4)](https://github.com/lioneil "lioneil (18 commits)")

---

Tags

hierarchicalmenusnested-structuressidebartreetreeviewhierarchytraversableadjacent

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[kartik-v/yii2-tree-manager

An enhanced tree management module with tree node selection and manipulation using nested sets.

156529.0k15](/packages/kartik-v-yii2-tree-manager)[markrogoyski/itertools-php

Iteration tools for PHP

14911.3k](/packages/markrogoyski-itertools-php)[fab2s/nodalflow

A PHP Nodal WorkFlow

16362.4k1](/packages/fab2s-nodalflow)[rinvex/laravel-menus

Rinvex Menus is a simple menu builder package for Laravel, that supports hierarchical structure, ordering, and styling with full flexibility using presenters for easy styling and custom structure of menu rendering.

294.0k20](/packages/rinvex-laravel-menus)[andreas-glaser/php-helpers

A comprehensive collection of PHP utility functions for array manipulation, string operations, date handling, HTML generation, form building, validation, and more. Modern PHP 8.2+ library with full type safety.

1386.5k2](/packages/andreas-glaser-php-helpers)

PHPackages © 2026

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