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

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

vouga/tree
==========

Library for managing adjacency list and nested set trees

10462PHP

Since Jan 7Pushed 12y agoCompare

[ Source](https://github.com/Humen/Tree)[ Packagist](https://packagist.org/packages/vouga/tree)[ RSS](/packages/vouga-tree/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Overview
========

[](#overview)

This library contains some useful methods in managing adjacency lists and nested set trees.

This library is still in beta. Most of the functionality works, but still needs improvement and benchmarking. You cannot modify your tree using this library. It's main usefulness at the moment is converting your trees from nested sets to adjacency lists and vice versa.

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

[](#requirements)

- PHP 5.3.0 or greater

Current Features
----------------

[](#current-features)

- Create POPO (plain old PHP objects) from your database trees (adjacency list or nested set)
- Convert your nested set to an adjacency list and vice-versa
- Tighten up a nested set that may be "loose".
- Easily add a level property to your nested set if you don't have one already.
- toArray and fromArray methods to easily add and retrieve your tree

To Do List
----------

[](#to-do-list)

- An integrity checker to check the integrity of your tree. Mainly useful for nested sets (ex: left and right domains have gone bad).
- Add toNestedArray method which will return the tree as a nested array instead of a flat array.
- Add, move, delete node functionality. Need to experiment with this a bit to optimize speed.
- Add some unit testing

### Basic Example

[](#basic-example)

```
