Skip to content

Instantly share code, notes, and snippets.

@janit
Last active January 27, 2016 06:15
Show Gist options
  • Save janit/35008a761dd9e177752e to your computer and use it in GitHub Desktop.
Save janit/35008a761dd9e177752e to your computer and use it in GitHub Desktop.
<?php
use Knp\Menu\MenuFactory;
use Knp\Menu\Renderer\ListRenderer;
$factory = new MenuFactory();
$menu = $factory->createItem('My menu');
$menu->addChild('Home', array('uri' => '/'));
$menu->addChild('Comments', array('uri' => '#comments'));
$menu->addChild('Symfony2', array('uri' => 'http://symfony-reloaded.org/'));
$menu->addChild('Coming soon');
$renderer = new ListRenderer(new \Knp\Menu\Matcher\Matcher());
echo $renderer->render($menu);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment