PHP code example of sugarcraft / sugar-crumbs

1. Go to this page and download the library: Download sugarcraft/sugar-crumbs 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/ */

    

sugarcraft / sugar-crumbs example snippets


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"

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"

use SugarCraft\Crumbs\Breadcrumb;
use SugarCraft\Zone\Manager;

$manager = new Manager();
$bc = (new Breadcrumb())->withZoneManager($manager);

echo $bc->render($stack);
// Each crumb is wrapped in a named APC zone: "crumb-0", "crumb-1", …
// The parent calls Manager::scan() on the output to record bounds,
// then routes MouseMsg through Manager::anyInBoundsAndUpdate().