PHPackages                             peterujah/hierarchical - 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. peterujah/hierarchical

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

peterujah/hierarchical
======================

Hierarchical - Light, simple PHP and mysql Hierarchy data and organization chart.

1.4(3y ago)519MITPHPPHP ^7.0 || ^8.0

Since Dec 14Pushed 3y ago2 watchersCompare

[ Source](https://github.com/peterujah/hierarchical)[ Packagist](https://packagist.org/packages/peterujah/hierarchical)[ Docs](https://github.com/peterujah/hierarchical)[ RSS](/packages/peterujah-hierarchical/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

PHP Hierarchical
================

[](#php-hierarchical)

Hierarchies represent relations between people or other types of related entities. The hierarchy structure determines which entities are in command of other entities.

Hierarchies can be stored in databases using table records that express what entities are below or above in the hierarchy tree.

This class can retrieve a hierarchy tree structure from a MySQL database table to easily visualize using the Google Organisation Chart API, Array or HTML.

[![alt text](https://github.com/peterujah/Hierarchical/raw/c0fcb5bc6be51763ae3a04d04e56694d682b7ec5/Screen%20Shot%202021-10-01%20at%206.12.50%20AM.png)](https://github.com/peterujah/Hierarchical/blob/c0fcb5bc6be51763ae3a04d04e56694d682b7ec5/Screen%20Shot%202021-10-01%20at%206.12.50%20AM.png)

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

[](#installation)

Installation is super-easy via Composer:

```
composer require peterujah/hierarchical
```

USAGES
======

[](#usages)

Hierarchical can be use as an array, html or google organizations chart

```
use Peterujah\NanoBlock\Hierarchical;
$hierarchy = new Hierarchical($conn, Hierarchical::LIST);
$hierarchy = new Hierarchical($conn, Hierarchical::HTML);
$hierarchy = new Hierarchical($conn, Hierarchical::CHART);
```

Assign new user to a position

```
 $hierarchy->add("foo22", "Foo")->under("vy7735");
```

Dump array

```
$hierarchy = new Hierarchical($conn, Hierarchical::LIST);
var_export($hierarchy->run("Peter", "vy7735"));
```

Display on google Organisation chart

```
google.charts.load('current', {packages:["orgchart"]});
  google.charts.setOnLoadCallback(drawChart);
  function drawChart() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Name');
    data.addColumn('string', 'Manager');
    data.addColumn('string', 'ToolTip');
    data.addRows(run("Peter", "vy7735");?>);
    var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
    chart.draw(data, {'allowHtml':true});
}
```

Initalisation options `new Hierarchical($conn, Hierarchical::CHART)`

OptionsDescriptionLISTRetrieve result as an arrayHTMLRetrieve result in HTML listCHARTRetrieve result in json data for google chart

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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.

###  Release Activity

Cadence

Every ~100 days

Total

4

Last Release

1311d ago

Major Versions

0.1 → 1.22022-05-07

### Community

Maintainers

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

---

Top Contributors

[![peterujah](https://avatars.githubusercontent.com/u/16369609?v=4)](https://github.com/peterujah "peterujah (40 commits)")

---

Tags

libraryhierarchicalphp classorganization-chartgoogle chartHierachyorganization hierachyphp hierachy classhierachy tree

### Embed Badge

![Health badge](/badges/peterujah-hierarchical/health.svg)

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

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)[dekor/php-array-table

PHP Library for printing associative arrays as text table (similar to mysql terminal console)

296.6M2](/packages/dekor-php-array-table)

PHPackages © 2026

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