1. Go to this page and download the library: Download changhorizon/directory-tree library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
changhorizon / directory-tree example snippets
use ChangHorizon\DirectoryTree\Viewer\DirectoryTreeViewer;
$viewer = new DirectoryTreeViewer();
echo $viewer->render('/path/to/directory');
namespace ChangHorizon\DirectoryTree\Node;
interface NodeInterface
{
public function getPath(): string;
public function getLocation(): string;
public function getParent(): ?NodeInterface;
public function addChild(NodeInterface $child): void;
public function getChildren(): ?array;
}
namespace ChangHorizon\DirectoryTree\Builder;
use ChangHorizon\DirectoryTree\Memory\TreeMemoryInterface;
use ChangHorizon\DirectoryTree\Node\NodeInterface;
interface TreeBuilderInterface
{
public function build(NodeInterface $root): TreeMemoryInterface;
}
namespace ChangHorizon\DirectoryTree\Memory;
use ChangHorizon\DirectoryTree\Node\NodeInterface;
interface TreeMemoryInterface
{
public function getRoot(): NodeInterface;
public function getAncestors(NodeInterface $node): array;
public function getSiblings(NodeInterface $node): array;
public function getDescendants(NodeInterface $node): array;
}