knplabs/knp-menu
Composer 安装命令:
composer require knplabs/knp-menu
包简介
An object oriented menu library
README 文档
README
The KnpMenu library provides object-oriented menus for PHP. It is used by the KnpMenuBundle for Symfony but can now be used stand-alone.
Installation
KnpMenu uses Composer, please check out the composer website for more information.
The simple following command will install knp-menu into your project. It also adds 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-menuclasses 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
docdirectory.
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) :
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/knp-menu 适用场景与选型建议
knplabs/knp-menu 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 58.27M 次下载、GitHub Stars 达 1.4k, 最近一次更新时间为 2011 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「menu」 「tree」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 knplabs/knp-menu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 knplabs/knp-menu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 knplabs/knp-menu 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
jsTree widget for yii2
A Symfony extension to get active class base on current bundle/controller/action
Doctrine2 behavior traits - slowhop fork
A fast and dynamic Merkle tree implementation
Data structure collections, helpers and utilities for yii2 ActiveRecord models(trees, sorts and etc.)
Yii2 DynaTree Menu widget uses Dynamic tree view control jquery.dynatree.js
统计信息
- 总下载量: 58.27M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1417
- 点击次数: 27
- 依赖项目数: 336
- 推荐数: 7
其他信息
- 授权协议: MIT
- 更新时间: 2011-11-07