icings/menu
Composer 安装命令:
composer require icings/menu
包简介
A KnpMenu seasoned menu plugin for CakePHP.
README 文档
README
A KnpMenu seasoned plugin that assists with creating menus for your CakePHP applications.
Requirements
- CakePHP 5.0+ (use the 4.x branch of this plugin if you need CakePHP 4 compatibility)
- KnpMenu 3.3+
Installation
-
Use Composer to add the menu plugin to your project:
$ composer require icings/menu
-
Make sure that you are loading the plugin in your bootstrap, either run:
$ bin/cake plugin load Icings/Menu
or add the following call to your
Applicationclass'bootstrap()method in thesrc/Application.phpfile:$this->addPlugin('Icings/Menu');
-
Load the helper in your
AppViewclass'initialize()method, located in thesrc/View/AppView.phpfile:$this->loadHelper('Icings/Menu.Menu');
Usage
Detailed usage documentation can be found in the docs folder. For those that are familiar with CakePHP and KnpMenu, here's two examples for a quick start.
Via the Menu helper
Build and render the menu via the helpers create() and render() methods:
$menu = $this->Menu->create('main'); $menu->addChild('Home', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'home']]); $menu->addChild('About', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'about']]); $menu->addChild('Services', ['uri' => '#']); $menu['Services']->addChild('Research', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'research']]); $menu['Services']->addChild('Security', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'security']]); $menu->addChild('Contact', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'contact']]); echo $this->Menu->render();
In the default setup, this would generate the following HTML:
<ul> <li> <a href="/pages/display/home">Home</a> </li> <li> <a href="/pages/display/about">About</a> </li> <li class="has-dropdown"> <a href="#">Services</a> <ul class="dropdown"> <li> <a href="/pages/display/research">Research</a> </li> <li> <a href="/pages/display/security">Security</a> </li> </ul> </li> <li> <a href="/pages/display/contact">Contact</a> </li> </ul>
Using the library directly
Aside from using the menu helper and its various configuration possibilities, it's also possible to manually utilize the library provided by this plugin, optionally combining things with the KnpMenu library:
use Icings\Menu\Integration\PerItemVotersExtension; use Icings\Menu\Integration\RoutingExtension; use Icings\Menu\Integration\TemplaterExtension; use Icings\Menu\Matcher\Matcher; use Icings\Menu\Matcher\Voter\UrlVoter; use Icings\Menu\MenuFactory; use Icings\Menu\Renderer\StringTemplateRenderer; $factory = new MenuFactory(); $factory->addExtension(new RoutingExtension()); $factory->addExtension(new PerItemVotersExtension()); $factory->addExtension(new TemplaterExtension()); $menu = $factory->createItem('main'); $menu->addChild('Home', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'home']]); $menu->addChild('About', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'about']]); $menu->addChild('Services', ['uri' => '#']); $menu['Services']->addChild('Research', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'research']]); $menu['Services']->addChild('Security', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'security']]); $menu->addChild('Contact', ['uri' => ['controller' => 'Pages', 'action' => 'display', 'contact']]); $matcher = new Matcher(); $matcher->addVoter(new UrlVoter($this->request)); $renderer = new StringTemplateRenderer($matcher); echo $renderer->render($menu);
Issues
Please use the issue tracker to report problems.
icings/menu 适用场景与选型建议
icings/menu 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 71.36k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2017 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「menu」 「cakephp」 「knp-menu」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 icings/menu 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 icings/menu 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 icings/menu 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
A Symfony extension to get active class base on current bundle/controller/action
Email Toolkit Plugin for CakePHP
Rhino, a CMS and Application-Framework plugin for CakePHP
A CakePHP plugin for sending mail via SparkPost's REST API
The package provides object-oriented menus for projects based on the Spiral Framework
统计信息
- 总下载量: 71.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-05-11