KnpMenu

Menu Library for PHP5

  • 所有者: KnpLabs/KnpMenu
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

KnpMenu

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

Build Status
Latest Stable Version
Latest Unstable Version
Gitter chat

Installation

KnpMenu uses Composer, please checkout the composer website for more information.

The simple following command will install knp-menu into your project. It also add a new
entry in your composer.json and update the composer.lock as well.

$ composer require knplabs/knp-menu

KnpMenu follows the PSR-4 convention names for its classes, which means you can easily integrate knp-menu classes loading in your own autoloader.

Getting Started

<?php

// Include dependencies installed with composer
require 'vendor/autoload.php';

use Knp\Menu\MenuFactory;
use Knp\Menu\Renderer\ListRenderer;

$factory = new MenuFactory();
$menu = $factory->createItem('My menu');
$menu->addChild('Home', ['uri' => '/']);
$menu->addChild('Comments', ['uri' => '#comments']);
$menu->addChild('Symfony', ['uri' => 'http://symfony.com/']);
$menu->addChild('Happy Awesome Developers');

$renderer = new ListRenderer(new \Knp\Menu\Matcher\Matcher());
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.com/">Symfony</a>
  </li>
  <li class="last">
    <span>Happy Awesome Developers</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.

What now?

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

Find all available documentation at doc/.

Maintainers

This library is maintained by the following people (alphabetically sorted) :

  • @derrabus
  • @garak
  • @stof

Credits

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

主要指标

概览
名称与所有者KnpLabs/KnpMenu
主编程语言PHP
编程语言PHP (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2011-08-08 15:39:40
推送于2025-02-28 08:30:18
最后一次提交2025-02-28 09:21:46
发布数32
最新版本名称v3.7.0 (发布于 )
第一版名称v1.0.0 (发布于 2011-12-03 17:14:19)
用户参与
星数1.4k
关注者数62
派生数195
提交数520
已启用问题?
问题数163
打开的问题数14
拉请求数159
打开的拉请求数9
关闭的拉请求数73
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?