Julio Montoya 033aa7a9bd Updating vendors and composer 11 yıl önce
..
doc 224a0e666e Updating vendors 11 yıl önce
src 3a484b8d25 Updating vendors 11 yıl önce
tests 3a484b8d25 Updating vendors 11 yıl önce
.travis.yml 40ae627f0b Updating vendor 12 yıl önce
CHANGELOG.md 3a484b8d25 Updating vendors 11 yıl önce
LICENSE 40ae627f0b Updating vendor 12 yıl önce
README.markdown 3a484b8d25 Updating vendors 11 yıl önce
composer.json 40ae627f0b Updating vendor 12 yıl önce
phpunit.xml.dist 3a484b8d25 Updating vendors 11 yıl önce

README.markdown

KnpMenu

The KnpMenu library provides object oriented menus for PHP 5.3. It is used by the KnpMenuBundle for Symfony2 but can now be used stand-alone.

Build Status Latest Stable Version Latest Unstable Version

<?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();
echo $renderer->render($menu);

The above menu would render the following HTML:

<ul>
  <li class="first">
    <a href="/">Home</a>
  </li>
  <li class="current">
    <a href="#comments">Comments</a>
  </li>
  <li>
    <a href="http://symfony-reloaded.org/">Symfony2</a>
  </li>
  <li class="last">
    <span>Coming soon</span>
  </li>
</ul>

This way you can finally avoid writing an ugly template to show the selected item, the first and last items, submenus, ...

The bulk of the documentation can be found in the doc directory.

Installation

KnpMenu does not provide an autoloader but follow the PSR-0 convention. You can use any compliant autoloader for the library, for instance the Symfony2 ClassLoader component. Assuming you cloned the library in vendor/KnpMenu, it will be configured this way:

<?php
$loader->registerNamespaces(array(
    'Knp\Menu' => __DIR__.'/vendor/KnpMenu/src'
    // ...
));

What now?

Follow the tutorial in doc/01-Basics-Menus.markdown and doc/02-Twig-Integration.markdown to discover how KnpMenu will rock your world!

Credits

This bundle was originally ported from ioMenuPlugin, a menu plugin for symfony1. It has since been developed by KnpLabs and the Symfony community.