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

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

timostamm/data-tree
===================

17.9k1PHP

Since Oct 4Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Tree data structure
=======================

[](#php-tree-data-structure)

This library provides a tree structure via discrete Traits.

It is intended to be used by other libraries.

### ChildrenTrait

[](#childrentrait)

Add, acces and remove child nodes using this trait.

### LookupTrait

[](#lookuptrait)

Optional methods to inspect the tree.

### AttributesTrait

[](#attributestrait)

Optional attributes per node.

### ToStringTrait

[](#tostringtrait)

Optional `__toString()` implementation that outputs the nodes class name and its attributes.

### NodeTrait

[](#nodetrait)

Combines all of the above traits

### Protected Access

[](#protected-access)

The sub-namespace `ProtectedAccess` contains versions of `ChildrenTrait`, `LookupTrait` and `AttributesTrait` where all methods are protected. This allows fine control over the public API when using the Traits in a library.

Example
-------

[](#example)

```
// Create a simple tree.
$root = new Node();
$root->setAttribute('name', 'root');

$a = new Node();
$a->setAttribute('name', 'a');
$root->addChild($a);

$b = new Node();
$b->setAttribute('name', 'b');
$root->addChild($b);

$c = new Node();
$c->setAttribute('name', 'c');
$root->addChild($c);

// Find a descendant with the name=b
$bAgain = $root->descendant(function ($node) {
	return $node->getAttribute('name') === 'b';
});

// Get the root node of any node
$rootAgain = $bAgain->findRootNode();

// Remove a node
$bAgain->remove();
$root->removeChild($a);
$root->removeChildAt(0);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6364011a12f22cb5046056371bde6170218218c560eddfdc08b4644b7648af78?d=identicon)[timostamm](/maintainers/timostamm)

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[pocketmine/bedrock-data

Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP

115418.0k5](/packages/pocketmine-bedrock-data)[nahid/qarray

QArray is a PHP abstraction for querying array

108403.2k2](/packages/nahid-qarray)[iben12/laravel-statable

Statable trait for Laravel Eloquent models

96299.8k1](/packages/iben12-laravel-statable)[flyntwp/acf-field-group-composer

52145.4k](/packages/flyntwp-acf-field-group-composer)[koriym/app-state-diagram

An Application Diagram Generator

38222.0k2](/packages/koriym-app-state-diagram)[terminal42/contao-leads

Leads extension for Contao Open Source CMS; Store and manage form data with ease!

41167.9k10](/packages/terminal42-contao-leads)

PHPackages © 2026

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