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

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

rebelcode/tree-rendering
========================

A PHP library for rendering trees and other similar hierarchies.

04PHP

Since Dec 10Pushed 7y ago2 watchersCompare

[ Source](https://github.com/RebelCode/tree-rendering)[ Packagist](https://packagist.org/packages/rebelcode/tree-rendering)[ RSS](/packages/rebelcode-tree-rendering/feed)WikiDiscussions develop Synced 5d ago

READMEChangelogDependenciesVersions (2)Used By (0)

RebelCode - Tree Rendering
==========================

[](#rebelcode---tree-rendering)

[![Build Status](https://camo.githubusercontent.com/996553700e0f9900d70fe99ce13b2d63e54b424be309f7f70a614e84997a2825/68747470733a2f2f7472617669732d63692e6f72672f526562656c436f64652f747265652d72656e646572696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/RebelCode/tree-rendering)[![Code Climate](https://camo.githubusercontent.com/aacd2c553a9d1b295b4fffa78cba2674c318973004e658b546994ee398e65d12/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f526562656c436f64652f747265652d72656e646572696e672f6261646765732f6770612e737667)](https://codeclimate.com/github/RebelCode/tree-rendering)[![Test Coverage](https://camo.githubusercontent.com/b7897fed9b64ea8f2545830b11e6ad6fdbe2f6e398a5719c89bcc8db19870de1/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f526562656c436f64652f747265652d72656e646572696e672f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/RebelCode/tree-rendering/coverage)[![Latest Stable Version](https://camo.githubusercontent.com/625fa0e5253b700bc7bd923c43ab1e16648bfe2ca3b4a7d6b67f02f2918096ef/68747470733a2f2f706f7365722e707567782e6f72672f726562656c636f64652f747265652d72656e646572696e672f76657273696f6e)](https://packagist.org/packages/rebelcode/tree-rendering)

A lightweight PHP library for rendering trees and other similar hierarchies.

Requirements 🛠
--------------

[](#requirements-)

PHP 5.4 or later.

Installation ⬇
--------------

[](#installation-)

```
composer require rebelcode/tree-rendering

```

Features ⭐
----------

[](#features-)

- Simple and intuitive interfaces
- Lightweight implementation with minimal overhead
- Master-slave pattern for simple per-node rendering and delegation
- Suitable for trees, nested structures and other similar hierarchical data structures

How it works 📖
--------------

[](#how-it-works-)

A **master** renderer instance is instantiated with a container of slave renderers. This renderer acts as the main entry point for all rendering.

```
$renderer = new MasterTreeRenderer(new Container([
    'slave_1' => new MySlaveRenderer(),
    // ...
]));
```

When the master renderer's `render()` method is called, the master renderer will use the node's *render type* string to determine which slave renderer should be used for rendering. The chosen slave is then told to `render()` the node, receiving both the node and the master renderer as parameters.

Slave renderers are not required to know how to render the entire node/subtree, and may use the master renderer reference (that they receive as the second parameter) to further delegate certain rendering to other slaves. Optionally, the slave may request that the master treats a node with a different render type.

```
class MySlaveRenderer implements SlaveTreeRendererInterface
{
    public function render(RenderNodeInterface $node, TreeRendererInterface $master)
    {
        if (! $node instanceof UserNodeInterface) {
            throw new InvalidArgumentException();
        }

        $name = $node->getName();
        $friends = $node->getFriends();

        // Delegate back to the master renderer, using `user_list` as the render type
        $list = $master->render($friends, 'user_list');

        return sprintf('[%s] %s', $name, $list);
    }
}
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

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/a8036caaa483e3f8a21d0083284bd508f5ada08ad45b790b5075ecff49f09b6b?d=identicon)[rebelcode](/maintainers/rebelcode)

---

Top Contributors

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

---

Tags

hierarchymaster-slavephprenderingtree

### Embed Badge

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

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

###  Alternatives

[pelmered/fake-car

Fake-Car is a Faker provider that generates fake car data for you.

1271.2M2](/packages/pelmered-fake-car)

PHPackages © 2026

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