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

ActiveLibrary

luizalbertoni/tree-parser
=========================

Parse tree structure

1.0.2(2y ago)05MITPHPPHP &gt;=7.0

Since Jan 17Pushed 2y agoCompare

[ Source](https://github.com/luiz-albertoni/php-tree-parser)[ Packagist](https://packagist.org/packages/luizalbertoni/tree-parser)[ Docs](https://github.com/baopham/tree-parser)[ RSS](/packages/luizalbertoni-tree-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

tree-parser
===========

[](#tree-parser)

[![Latest Stable Version](https://camo.githubusercontent.com/56ecb7a0a68ee6c9175ca173907bebba6ecc76c725a55186aed0665b97715403/68747470733a2f2f706f7365722e707567782e6f72672f62616f7068616d2f747265652d7061727365722f762f737461626c65)](https://packagist.org/packages/baopham/tree-parser)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/856e784e954c06206257be436bb11d2b931aaf12da7146d1b69120d4adde2f73/68747470733a2f2f7472617669732d63692e6f72672f62616f7068616d2f7068702d747265652d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/baopham/php-tree-parser)[![Code Coverage](https://camo.githubusercontent.com/a47d37d07631adec1e9d396e2f47258b22bce86f5b6fabed58f09f2869296e1e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62616f7068616d2f7068702d747265652d7061727365722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/baopham/php-tree-parser/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/cb9ea00bd86fdb2e63e4635e89b1b62818057522afda520a58fd8ee133ffe24e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62616f7068616d2f7068702d747265652d7061727365722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/baopham/php-tree-parser/?branch=master)

Parse this:

```
   Root
     |- Level 1.1
       |- Level 2.1
     |- Level 1.2
       |- Level 2.2
         |- Level 3
           |- Level 4

```

to this:

```
foreach ($root->children as $child) {
    print $child->name;

    print $child->order;

    print $child->level;

    print_r($child->children);

    print_r($child->children[0]->children);

    print $child->children[0]->parent === $child;
}
```

Table of Content
----------------

[](#table-of-content)

- [Install](#install)
- [Usage](#usage)
    - [Advanced](#advanced)
- [Change log](#change-log)
- [Testing](#testing)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Install
-------

[](#install)

Via Composer

```
$ composer require baopham/tree-parser
```

Usage
-----

[](#usage)

```
// A tree with 2 spaces for indentation
$tree = children as $child) {
    print $child->name;

    print $child->order;

    print $child->level;

    print_r($child->children);

    print_r($child->children[0]->children);

    print $child->children[0]->parent === $child;
}
```

### Advanced

[](#advanced)

```
$tree = getOrderedNodes();
$lastLeaf = $orderedNodes[count($orderedNodes) - 1];
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Credits
-------

[](#credits)

- [Bao Pham](https://github.com/baopham)

License
-------

[](#license)

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

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 85.7% 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

Unknown

Total

1

Last Release

843d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f4ecb02d128ce6a62f06db86693fc6224accc7dccf8a30fec1ebf490a6457b5?d=identicon)[luiz.albertoni](/maintainers/luiz.albertoni)

---

Top Contributors

[![baopham](https://avatars.githubusercontent.com/u/783410?v=4)](https://github.com/baopham "baopham (12 commits)")[![luiz-albertoni](https://avatars.githubusercontent.com/u/14180436?v=4)](https://github.com/luiz-albertoni "luiz-albertoni (2 commits)")

---

Tags

tree-parserbaophamluizalbertoni

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

PHPackages © 2026

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