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

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

nayjest/tree
============

Tree data structure for PHP

v3.2.1(10y ago)7114.1k↓17.5%[2 issues](https://github.com/Nayjest/Tree/issues)5MITPHPPHP &gt;=5.4.0

Since Jul 21Pushed 9y ago2 watchersCompare

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

READMEChangelog (10)Dependencies (2)Versions (27)Used By (5)

Tree
====

[](#tree)

Tree data structure for PHP

[![Build Status](https://camo.githubusercontent.com/e621d9db8910d2304c917ecda26ee0079a6afc5f832fdee016b0bb579056e173/68747470733a2f2f7472617669732d63692e6f72672f4e61796a6573742f547265652e737667)](https://travis-ci.org/Nayjest/Tree)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5441276388c8ff67588c2b3b37b8d552265c1de8c935a7ad47379be7ac1e3b78/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4e61796a6573742f547265652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Nayjest/Tree/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/7b08247a14b1ee1f159ad797cd01cc804bf125283cc7c65f5d641b243f28095e/68747470733a2f2f706f7365722e707567782e6f72672f6e61796a6573742f747265652f762f737461626c65)](https://packagist.org/packages/nayjest/tree)

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

[](#requirements)

- php 5.4+

Installation
------------

[](#installation)

The recommended way of installing the component is through [Composer](https://getcomposer.org).

Run following command:

```
composer require nayjest/tree
```

Overview
--------

[](#overview)

#### Tree Nodes

[](#tree-nodes)

Nodes are basic tree elements. This package represents tree nodes as instances of Nayjest\\Tree\\Node. Since nodes here don't holds any functionality beyond the scope of organizing into a trees, the package is designed for extending its components functionality in different ways:

- Extend base classes (Node, ReadonlyNode)
- Provide your own implementations of ParentNodeInterface and ChildNodeInterface
- Use traits (NodeTrait, ChildNodeTrait, ParentNodeTrait, ReadonlyNodeTrait) and interfaces if you can't use node classes as base classes

#### Node Collections

[](#node-collections)

Each node stores its children inside instance of Nayjest\\Tree\\NodeCollection.

This package uses [nayjest/collections](https://github.com/Nayjest/Collection) for working with collections.

Class Nayjest\\Tree\\NodeCollection provides consistency of parent-child node relations.

It means that if you will add node to collection, this node will be automatically attached to parent node associated with collection, if you will remove node from collection, node will be detached from parent node.

#### Trees

[](#trees)

Class Nayjest\\Tree\\Tree allows to:

- organize trees with **named nodes** (nodes itself don't store information about its name, class Tree works with any objects that implements NodeInterface)
- build *tree based on hierarchy configuration* (multidimantional array containing only node names) and registry of nodes(associative array where keys are names and values are nodes)
- **manipulate named nodes** in convenient way (Tree API)
- **protect tree structure** from modifying via Node API methods to avoid inconsistency of node relations.

#### Nayjest\\Tree\\Utils

[](#nayjesttreeutils)

This class is a facade for helper functions.

Testing
-------

[](#testing)

Run following command:

```
phpunit
```

License
-------

[](#license)

© 2014—2016 Vitalii Stepanenko

Licensed under the MIT License.

Please see [License File](LICENSE) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 92.2% 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 ~7 days

Recently: every ~18 days

Total

25

Last Release

3764d ago

Major Versions

v0.3.1 → v1.0.02015-09-09

v1.5.2 → v2.0.0-beta32015-11-11

v2.0.0 → v3.0.02016-01-20

### Community

Maintainers

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

---

Top Contributors

[![Nayjest](https://avatars.githubusercontent.com/u/153999?v=4)](https://github.com/Nayjest "Nayjest (59 commits)")[![globotech-acc](https://avatars.githubusercontent.com/u/10062496?v=4)](https://github.com/globotech-acc "globotech-acc (5 commits)")

---

Tags

treehierarchydata structuretrees

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[knplabs/knp-menu

An object oriented menu library

1.4k55.8M287](/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)[loophp/phptree

An implementation of tree data structure

981.8M2](/packages/loophp-phptree)[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)[bluem/tree

Library for handling tree structures based on parent IDs

252916.1k7](/packages/bluem-tree)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

320392.1k17](/packages/codewithdennis-filament-select-tree)

PHPackages © 2026

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