mrsuh / tree-printer
Installs: 53
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mrsuh/tree-printer
Requires
- php: >= 7.4
 
Requires (Dev)
- phpunit/phpunit: ^9.6
 
This package is not auto-updated.
Last update: 2025-10-28 09:49:38 UTC
README
Installation
composer require mrsuh/tree-printer
Usage
<?php require_once __DIR__ . '/../vendor/autoload.php'; use Mrsuh\Tree\NodeInterface; use Mrsuh\Tree\Printer; class Node implements NodeInterface { private string $name; private array $children; public function __construct(string $name, array $children = []) { $this->name = $name; $this->children = $children; } public function getChildren(): array { return $this->children; } public function __toString(): string { return $this->name; } } $tree = new Node('/etc', [ new Node('adduser.conf'), new Node('apt', [ new Node('apt.conf.d', [ new Node('01autoremove'), new Node('70debconf') ]), new Node('auth.conf.d'), new Node('preferences.d'), new Node('trusted.gpg.d', [ new Node('debian-archive-bullseye-automatic.gpg'), new Node('debian-archive-bullseye-security-automatic.gpg'), new Node('debian-archive-bullseye-stable.gpg'), ]), ]), new Node('bash.bashrc'), new Node('cron.d', [ new Node('e2scrub_all'), ]), new Node('cron.daily', [ new Node('apt-compat'), new Node('dpkg'), ]) ]); $printer = new Printer(); $printer->print($ast);
.
├── /etc
    ├── adduser.conf
    ├── apt
    │   ├── apt.conf.d
    │   │   ├── 01autoremove
    │   │   └── 70debconf
    │   ├── auth.conf.d
    │   ├── preferences.d
    │   └── trusted.gpg.d
    │       ├── debian-archive-bullseye-automatic.gpg
    │       ├── debian-archive-bullseye-security-automatic.gpg
    │       └── debian-archive-bullseye-stable.gpg
    ├── bash.bashrc
    ├── cron.d
    │   └── e2scrub_all
    └── cron.daily
        ├── apt-compat
        └── dpkg