survos/tui-extras-bundle
Composer 安装命令:
composer require survos/tui-extras-bundle
包简介
Extra TUI widgets and data source abstractions for symfony/tui
README 文档
README
Extra TUI widgets and data-source abstractions for symfony/tui — the terminal UI component shipping in Symfony 8.1.
Status: 0.1 — beta. Tracks
symfony/tui ^8.1which is itself experimental. Widgets are usable and the file browser works end-to-end. APIs may shift before 1.0.
What's in the box
Widgets
| Widget | What it does |
|---|---|
DataTableWidget |
Paged, searchable, sortable data table. Live search, FTS5-aware. |
TreeWidget |
Collapsible tree — ▼/► branches, ── leaves. Keyboard navigate. |
DetailPanelWidget |
Read-only text/code pane with title and separator. |
Data sources (TuiTableSourceInterface)
| Source | Backed by |
|---|---|
ArrayTableSource |
Plain PHP array, in-memory filter/sort |
SqliteTableSource |
PDO + SQLite with optional FTS5 full-text search |
FileSource |
Symfony Finder — respects .gitignore by default |
Syntax highlighting (SyntaxHighlighter)
- Uses
bat/batcatif installed (200+ languages, themes) - PHP fallback via
token_get_all()— zero extra deps - JSON fallback via stdlib pretty-print + hand-rolled tokenizer
- Markdown via
MarkdownWidget(league/commonmark + tempest/highlight)
Requirements
- PHP 8.1+
symfony/tui ^8.1(currently8.1.x-dev)league/commonmark ^2.0(for Markdown rendering)tempest/highlight ^2.0(for code blocks within Markdown)
Installation
composer require survos/tui-extras-bundle
Register in your config/bundles.php (or let Flex do it):
Survos\TuiExtrasBundle\SurvosTuiExtrasBundle::class => ['all' => true],
HTTP-less apps (
AbstractKernel+KernelTrait+ConsoleBundle, noFrameworkBundle): the bundle works without an HTTP kernel. See thedemo/directory for a minimal setup.
The file browser
The fastest way to see the bundle in action:
cd demo/ composer install php bin/console browse:files # tree of current directory php bin/console browse:files ../src # browse the bundle source php bin/console browse:files . --pre-expand=2 # open 2 levels on start php bin/console browse:files . --raw # no syntax highlighting php bin/console browse:files . --no-gitignore # include ignored files
▼ src/
── ► Event/
▼ Highlighter/
──── SyntaxHighlighter.php
▼ Model/
──── TreeNode.php
──── TuiColumn.php
▼ Widget/
──── DataTableWidget.php │ <?php
──── DetailPanelWidget.php │
──── TreeWidget.php │ declare(strict_types=1);
▼ Source/ │
──── ArrayTableSource.php │ namespace Survos\TuiExtrasBundle\Highlighter;
──── FileSource.php │
──── SqliteTableSource.php │ /**
│ * Syntax highlighter that emits ANSI-colored
│ * lines compatible with DetailPanelWidget.
Keybindings:
| Key | Action |
|---|---|
↑ / ↓ / j / k |
Navigate |
→ |
Expand directory |
← |
Collapse (or jump to parent) |
Enter / Space |
Toggle directory / preview file |
q / ctrl+c |
Quit |
Preview updates instantly as you navigate — no Enter required for files. PHP and JSON files are syntax-highlighted. Markdown files render with full formatting.
FTS5 full-text search demo
php bin/console browse:functions # ~1300 PHP internal functions, SQLite FTS5
Type / then str_ to filter to all string functions instantly. Uses an in-memory
SQLite database with an FTS5 virtual table — the same pattern FolioRowTableSource
uses in survos/folio-bundle.
Building a split-pane browser
use Survos\TuiExtrasBundle\Model\TreeNode; use Survos\TuiExtrasBundle\Widget\DetailPanelWidget; use Survos\TuiExtrasBundle\Widget\TreeWidget; use Symfony\Component\Tui\Style\Direction; use Symfony\Component\Tui\Style\Style; use Symfony\Component\Tui\Style\StyleSheet; use Symfony\Component\Tui\Tui; use Symfony\Component\Tui\Widget\ContainerWidget; $tree = new TreeWidget(); $tree->addRoot(TreeNode::branch('src/', null, true) ->addChild(TreeNode::leaf('Kernel.php', 'src/Kernel.php')) ->addChild(TreeNode::branch('Command/') ->addChild(TreeNode::leaf('MyCommand.php', 'src/Command/MyCommand.php')) ) ); $detail = new DetailPanelWidget(); $tree->onCursorChange(fn($e) => $detail->setContent( file_get_contents($e->node->data ?? ''), (string) $e->node->data, )); $split = (new ContainerWidget())->setStyle(new Style(direction: Direction::Horizontal, gap: 1)); $split->add($tree->setStyle(new Style(maxColumns: 40))); $split->add($detail); $tui = new Tui(new StyleSheet()); $tui->add($split); $tui->setFocus($tree); $tui->run();
Building a DataTable with SQLite FTS5
use Survos\TuiExtrasBundle\Model\TuiColumn; use Survos\TuiExtrasBundle\Source\SqliteTableSource; use Survos\TuiExtrasBundle\Widget\DataTableWidget; $pdo = new \PDO('sqlite:/path/to/data.sqlite'); // FTS5 virtual table: CREATE VIRTUAL TABLE fts_items USING fts5(name, description, content=items, content_rowid=id) $source = new SqliteTableSource( pdo: $pdo, table: 'items', ftsTable: 'fts_items', columns: [ new TuiColumn(key: 'name', label: 'Name', sortable: true, searchable: true), new TuiColumn(key: 'description', label: 'Description', searchable: true), new TuiColumn(key: 'created_at', label: 'Created', width: 12, format: 'date', sortable: true), ], ); $table = new DataTableWidget($source); // Press / to search with FTS5, ↑↓ navigate, s sort, q quit
TuiTableSourceInterface
Implement this to make any data source browsable:
interface TuiTableSourceInterface { /** @return TuiColumn[] */ public function columns(): array; public function count(?string $search = null): int; /** @return iterable<array<string,mixed>> */ public function rows(int $offset = 0, int $limit = 25, ?string $search = null, ?string $sortBy = null, string $sortDir = 'ASC'): iterable; }
Built-in implementations: ArrayTableSource, SqliteTableSource, FileSource.
Adapters in other bundles: FolioRowTableSource (survos/folio-bundle), JsonlTableSource (survos/jsonl-bundle, planned).
Roadmap
-
browse:commands—vendor/bin/browsecommand browser (tree of namespaces + full--helpin detail pane) -
FolioRowTableSource— FTS5-backed browser for survos/folio-bundle -
MeilisearchTableSource+browse:meili— live Meilisearch browser - Generic SQLite schema browser (squall-style: table tree + row DataTable)
- PHAR packaging via humbug/box (
vendor/bin/browse)
License
MIT
survos/tui-extras-bundle 适用场景与选型建议
survos/tui-extras-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 50 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「terminal」 「widget」 「datatable」 「tui」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 survos/tui-extras-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 survos/tui-extras-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 survos/tui-extras-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A fork of runcmf/runtracy
PHP Terminal emulator controller utilizing ANSI escape sequence coding.
The bundle for easy using json-rpc api on your project
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
Bundle Symfony DaplosBundle
Add a weather widget to Flarum
统计信息
- 总下载量: 50
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-15