PHPackages                             helbrary/node-item-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. helbrary/node-item-tree

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

helbrary/node-item-tree
=======================

Tree structure library.

v1.2.3(9y ago)17.5kBSD-3-ClausePHPPHP &gt;= 5.5.0

Since Dec 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/krajcikondra/nodeItemTree)[ Packagist](https://packagist.org/packages/helbrary/node-item-tree)[ RSS](/packages/helbrary-node-item-tree/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (7)Used By (0)

NodeItemTree
============

[](#nodeitemtree)

[![Alt text](images/tree.png?raw=true "Tree")](images/tree.png?raw=true)

Example: Products in categories

Imagine that nodes are categories and items are products.

```
$tree->addNode(1, 'All categories', array()); // root

// subcategories of category 'All categories'
$tree->addNode(2, 'Computer', array(), 1);
$tree->addNode(3, 'Wifi', array(), 1);
$tree->addNode(4, 'other', array(), 1);

$tree->addNode(5, 'Gaming computer', array(), 2);

// add products to categories
$tree->addItem(2, 1448, 'My super computer', array('price' => 15000));  // 1448 = id of product
$tree->addItem(3, 1453, 'My super wifi', array('price' => 800));  // 1453 = id of product
$tree->addItem(4, 1350, 'My super printer', array('price' => 800));  // 1350 = id of product

//instead of array with information we can put object

$product = $db->getProduct(1351);
$tree->addItem(4, $product->id,  $product->name, $product);

```

And then we can render tree

```
foreach ($tree->findRootNodes() as $rootCategories) {

  foreach ($node->findNodes() as $subCategory) {

  echo $subCategory->getValue(); // name of category

    foreach ($subcategory->findItems() as $product) {
      echo "- " . $product->getValue();     // name of product
    }
  }
}
```

Render items of node

```
$node = $tree->getNode(1);
$items = $node->findItems(); // return all items which are direct in node with key 1

$items = $node->findItems(TRUE); // return all items in node 1 and all items in all descendants of node 1
```

Path to node

```
$pathToNodes = $tree->getPathToNode(5);
foreach ($pathToNodes as $node) {
  echo '- ' . $node->getValue();
}

// output will be:  All  categories - Computer - Gaming computer

// if we do not want render last node 'Gaming computer' then we must set second parameter of method getPathToNode to FALSE

$pathToNodes = $tree->getPathToNode(5, FALSE);
foreach ($pathToNodes as $node) {
  echo '- ' . $node->getValue();
}

// output will be:  All  categories - Computer

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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

Recently: every ~74 days

Total

6

Last Release

3531d ago

PHP version history (2 changes)v1.0PHP &gt;= 5.3.7

v1.2.2PHP &gt;= 5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/abcd971025e7368820d6f85446fd352e22c514b91aa52b81f87ca9d94268f158?d=identicon)[krajcikondra](/maintainers/krajcikondra)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/helbrary-node-item-tree/health.svg)

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

###  Alternatives

[nette/code-checker

✅ Nette CodeChecker: A simple tool to check source code against a set of Nette coding standards.

891.7M6](/packages/nette-code-checker)[nextras/datagrid

Datagrid component for Nette Framework.

71270.4k4](/packages/nextras-datagrid)[efabrica/phpstan-latte

4511.9k](/packages/efabrica-phpstan-latte)[uestla/twigrid

Experimental DataGrid for Nette Framework

1712.3k2](/packages/uestla-twigrid)

PHPackages © 2026

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