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

ActiveLibrary

dbeurive/tree
=============

This package contains a list of PHP utilities used to manipulate trees

1.0.4(9y ago)0501MITPHP

Since Apr 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dbeurive/tree)[ Packagist](https://packagist.org/packages/dbeurive/tree)[ RSS](/packages/dbeurive-tree/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (6)Used By (1)

Description
===========

[](#description)

This package implements various tree utilities.

Installation
============

[](#installation)

From the command line:

```
composer require dbeurive/tree

```

From your `composer.json` file:

```
{
    "require": {
        "dbeurive/tree": "1.0.*"
    }
}
```

API documentation
=================

[](#api-documentation)

The detailed documentation of the API can be extracted from the code by using [PhpDocumentor](https://www.phpdoc.org/). The file `phpdoc.xml` contains the required configuration for `PhpDocumentor`. To generate the API documentation, just move into the root directory of this package and run `PhpDocumentor` from this location.

Note:

> Since all the PHP code is documented using PhpDoc annotations, you should be able to exploit the auto completion feature from your favourite IDE. If you are using Eclipse, NetBeans or PhPStorm, you probably won’t need to consult the generated API documentation.

Since the API is quite simple and intuitive, the present document presents examples of code. These examples are located under the directory `examples`.

Examples
========

[](#examples)

All examples are based on the tree which structure is represented by the figure below.

[![Image of the tree](https://github.com/dbeurive/tree/raw/master/doc/tree.gif)](https://github.com/dbeurive/tree/blob/master/doc/tree.gif)

**[treeObject.php](https://github.com/dbeurive/tree/blob/master/examples/treeObject.php)**: this example shows how to create a tree using the tree builder. It creates an instance of class `\dbeurive\Tree\Tree`.

**[treeArray.php](https://github.com/dbeurive/tree/blob/master/examples/treeArray.php)**: this example illustrates the procedure to create a tree (an object of class `\dbeurive\Tree\Tree`) from an array of imbricated arrays.

**[treeObjectTraverse.php](https://github.com/dbeurive/tree/blob/master/examples/treeObjectTraverse.php)**: this example shows how to traverse a tree that is an object of class `\dbeurive\Tree\Tree`.

**[treeArrayTravserse.php](https://github.com/dbeurive/tree/blob/master/examples/treeArrayTravserse.php)**: this example shows how to traverse a tree represented by an array of imbricated arrays.

**[search.php](https://github.com/dbeurive/tree/blob/master/examples/search.php)**: this example shows how to search for a node's data within the entire tree.

**[treeObjectToArray.php](https://github.com/dbeurive/tree/blob/master/examples/treeObjectToArray.php)**: this example shows how to convert a tree defined as an object of class `\dbeurive\Tree\Tree` into the "array representation" (an array of imbricated arrays).

**[treeToDot.php](https://github.com/dbeurive/tree/blob/master/examples/treeToDot.php)**: this example shows how to produce a "GRAPHVIZ" representation of a tree.

**[treeObjectTraverseSerialize.php](https://github.com/dbeurive/tree/blob/master/examples/treeObjectTraverseSerialize.php)**: this example shows how to use objects (instead of scalars) as nodes' data. We create a tree that contains objects. Then we traverse the tree and we serialise all nodes. Please note that the tree is represented by an object of class `\dbeurive\Tree\Tree`.

**[treeArrayTravserseSerialize.php](https://github.com/dbeurive/tree/blob/master/examples/treeArrayTravserseSerialize.php)**: this example shows how to use objects (instead of scalars) as nodes' data. We create a tree that contains objects. Then we traverse the tree and we serialise all nodes. Please note that the tree is represented by an array of imbricated arrays.

**[treeIndex.php](https://github.com/dbeurive/tree/blob/master/examples/treeIndex.php)**: this example shows how to create an index that references all nodes within the tree. Indexes are generated from the nodes' data. Please note that, in this example, we assume that all nodes have a unique data value.

**[treeIndexMulti.php](https://github.com/dbeurive/tree/blob/master/examples/treeIndexMulti.php)**: this example shows how to create an index that references all nodes within the tree. Indexes are generated from the nodes' data. Please note that, in this example, we assume that multiple nodes may have the same data value.

**[treeSelect.php](https://github.com/dbeurive/tree/blob/master/examples/treeSelect.php)**: this example shows how to select nodes based on their data's values.

**[treeSearch.php](https://github.com/dbeurive/tree/blob/master/examples/treeSearch.php)**: this example shows how search for nodes with given values.

**[nodes.php](https://github.com/dbeurive/tree/blob/master/examples/nodes.php)**: this example illustrates various operations on nodes.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

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

Total

5

Last Release

3594d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2608f031e92b087ec62521ea3c7c9cc5f3fc53c9fedb346aadceb39039532b5f?d=identicon)[dbeurive](/maintainers/dbeurive)

---

Top Contributors

[![dbeurive](https://avatars.githubusercontent.com/u/18211524?v=4)](https://github.com/dbeurive "dbeurive (8 commits)")

---

Tags

tree

### Embed Badge

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

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

###  Alternatives

[gedmo/doctrine-extensions

Doctrine behavioral extensions

4.1k118.8M365](/packages/gedmo-doctrine-extensions)[stof/doctrine-extensions-bundle

Integration of the gedmo/doctrine-extensions with Symfony

1.9k85.3M381](/packages/stof-doctrine-extensions-bundle)[knplabs/knp-menu

An object oriented menu library

1.4k55.8M285](/packages/knplabs-knp-menu)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[knplabs/doctrine-behaviors

Doctrine Behavior Traits

92212.7M64](/packages/knplabs-doctrine-behaviors)[bluem/tree

Library for handling tree structures based on parent IDs

252916.1k7](/packages/bluem-tree)

PHPackages © 2026

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