adachsoft/file-tree-render
Composer 安装命令:
composer require adachsoft/file-tree-render
包简介
A flexible PHP library for rendering file system trees in various formats (Markdown, JSON, XML, HTML) with customizable metadata and filtering.
README 文档
README
A flexible PHP library for rendering file system trees in various formats (Markdown, JSON, XML, HTML). It supports filtering, metadata enrichment (file size, permissions), and includes a CLI tool.
Features
- Multiple Output Formats: Markdown (ASCII tree), JSON, XML, HTML.
- Filtering: Whitelist file extensions and exclude specific directories.
- Metadata: Optionally display file sizes and permissions.
- Security: Uses
adachsoft/normalized-safe-pathto prevent path traversal. - CLI Tool: Includes a
render-treebinary for command-line usage. - Customizable: Fluent Builder pattern for easy configuration.
Installation
composer require adachsoft/file-tree-render
Usage
Basic Usage
use AdachSoft\FileTreeRender\FileTreeRenderBuilder;
$renderer = (new FileTreeRenderBuilder())
->withBasePath(__DIR__) // Set the root directory to scan
->build();
// Render the tree relative to the base path
echo $renderer->render('.');
Advanced Configuration
use AdachSoft\FileTreeRender\FileTreeRenderBuilder;
use AdachSoft\FileTreeRender\Renderer\JsonTreeRenderer;
$renderer = (new FileTreeRenderBuilder())
->withBasePath('/var/www/project')
// Only show these extensions
->withAllowedExtensions(['php', 'md', 'json'])
// Exclude these directories from recursion
->withExcludedDirectories(['vendor', 'node_modules', '.git'])
// Optionally show excluded items (without recursing into them)
->withShowExcludedDirectories(true)
->withShowExcludedFiles(true)
// Enable metadata addons
->withAddons(['filesize', 'permissions'])
// Use a specific renderer (default is Markdown)
->withRenderer(new JsonTreeRenderer())
->build();
echo $renderer->render('src');
Available Renderers
MarkdownTreeRenderer(Default): Generates a text-based tree suitable for Markdown files or console output.JsonTreeRenderer: Generates a JSON representation of the tree.XmlTreeRenderer: Generates an XML representation.HtmlTreeRenderer: Generates an HTML unordered list (<ul>).
CLI Tool
The package comes with a binary bin/render-tree that can be used directly from the command line.
# Basic usage (renders current directory in Markdown)
./bin/render-tree
# Render a specific subdirectory
./bin/render-tree src
# Output as JSON
./bin/render-tree src --format=json
# Disable metadata
./bin/render-tree --no-metadata
# Show excluded directories (e.g. vendor) but don't recurse into them
./bin/render-tree --show-excluded-dirs
Options:
path: Path relative to project root (default:.)format: One of:markdown,md,json,xml,html(default:markdown)--metadata=default: Enable default metadata providers (size, permissions)--metadata=none/--no-metadata: Disable metadata--show-excluded-dirs: Show excluded directories (without recursion)--show-excluded-files: Show excluded files--dump-metadata: Print a debug tree with raw node metadata
Testing
composer test
License
MIT
adachsoft/file-tree-render 适用场景与选型建议
adachsoft/file-tree-render 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「tree」 「filesystem」 「cli」 「markdown」 「render」 「visualization」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 adachsoft/file-tree-render 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 adachsoft/file-tree-render 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 adachsoft/file-tree-render 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A PHP class providing static methods for reading, writing, copying, moving, and deleting files and directories, MIME type detection, image size detection, and file permission management
jsTree widget for yii2
The flysystem adapter for yandex disk rest api.
Doctrine2 behavior traits - slowhop fork
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-21