sugarcraft / sugar-crumbs
PHP port of KevM/bubbleo — NavStack and Breadcrumb components. Push/pop navigation stack with hierarchical breadcrumb rendering for terminal UIs.
v0.2.0
2026-05-07 01:29 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^10.5
This package is not auto-updated.
Last update: 2026-05-07 14:55:32 UTC
README
SugarCrumbs
PHP port of KevM/bubbleo — NavStack (navigation stack) and Breadcrumb components for terminal UIs.
Features
- NavStack — hierarchical navigation state with push/pop/peek operations
- Breadcrumb renderer — renders the current navigation path as a clickable-looking breadcrumb string
- Shell — combines NavStack + Breadcrumb into a single component
- Pure renderer — breadcrumb output is just strings; works with any TUI framework
- No external dependencies — pure PHP 8.1+
Install
composer require sugarcraft/sugar-crumbs
NavStack Quick Start
use SugarCraft\Crumbs\NavStack; $stack = new NavStack(); // Push navigation items (each has a title + optional data) $stack->push('Home'); $stack->push('Settings'); $stack->push('Display'); // Current item echo $stack->current()->title; // "Display" echo $stack->depth(); // 3 // Pop back $popped = $stack->pop(); echo $popped->title; // "Display" echo $stack->current()->title; // "Settings"
Breadcrumb Rendering
use SugarCraft\Crumbs\Breadcrumb; $bc = new Breadcrumb(); $bc->setSeparator(' › '); // default " › " $bc->setMaxWidth(60); // truncate if needed // Render from NavStack $stack = new NavStack(); $stack->push('Home'); $stack->push('Settings'); $stack->push('Display'); echo $bc->render($stack); // "Home › Settings › Display"