PHPackages                             dimasp/generictree - 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. dimasp/generictree

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

dimasp/generictree
==================

N-ary Tree

015PHP

Since Apr 29Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Zetzumarshen/GenericTree)[ Packagist](https://packagist.org/packages/dimasp/generictree)[ RSS](/packages/dimasp-generictree/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

GenericTree
===========

[](#generictree)

N-ary tree with higher order function while traversing.

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

[](#requirements)

- PHP 5.4.0 or later

Usage:
------

[](#usage)

```
use DimasP\GenericTree as Tree;

require_once 'GenericTree.php';

$tree = new Tree\GenericTree();

$tree->insert(array (), "1");
$tree->insert(array (), "2");
$tree->insert(array (), "3");
$tree->insert(array (), "4");
$tree->insert(array (3), "4,1");
$tree->insert(array (3), "4,2");
$tree->insert(array (2), "3,1");
$tree->insert(array (2, 0), "3,1,1");

$preOp = function () {
	echo "(";
};
$inOp = function ($arg) {
	echo " $arg ";
};
$postOp = function () {
	echo ")";
};

$tree->inOrder($preOp, $inOp, $postOp);
// prints ( 1 () 2 () 3 ( 3,1 ( 3,1,1 ())) 4 ( 4,1 () 4,2 ()))

```

Or alternatively you can remove this line in `GenericTree.php` and `Node.php`:

```
namespace DimasP\GenericTree;

```

and this line:

```
use Exception;

```

And load the library using `require_once`.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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/3189949?v=4)[zetzumarshen](/maintainers/zetzumarshen)[@Zetzumarshen](https://github.com/Zetzumarshen)

### Embed Badge

![Health badge](/badges/dimasp-generictree/health.svg)

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

###  Alternatives

[mitch/hashids

Laravel package for Hashids

105111.7k](/packages/mitch-hashids)

PHPackages © 2026

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