# menu **Repository Path**: mirrors_CakeDC/menu ## Basic Information - **Project Name**: menu - **Description**: A KnpMenu seasoned menu plugin for CakePHP. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-03-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Menu [![Build Status][ico-travis]][link-travis] [![Coverage Status][ico-coverage]][link-coverage] [![Latest Version][ico-version]][link-version] [![Software License][ico-license]][link-license] [ico-travis]: https://img.shields.io/travis/icings/menu/master.svg?style=flat-square [ico-coverage]: https://img.shields.io/codecov/c/github/icings/menu.svg?style=flat-square [ico-version]: https://img.shields.io/packagist/v/icings/menu.svg?style=flat-square&label=latest [ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square [link-travis]: https://travis-ci.org/icings/menu [link-coverage]: https://codecov.io/github/icings/menu [link-version]: https://packagist.org/packages/icings/menu [link-license]: LICENSE.txt A [KnpMenu](https://github.com/KnpLabs/KnpMenu) seasoned plugin that assists with creating menus for your CakePHP applications. ## Requirements * CakePHP 3.1+ * KnpMenu 2.0+ ## Installation 1. Use [Composer](http://getcomposer.org) to add the menu plugin to your project: ```bash $ composer require icings/menu ``` 2. Make sure that you are loading the plugin in your bootstrap, either run: ```bash $ bin/cake plugin load Icings/Menu ``` or add the following call to your applications `config/bootstrap.php` manually: ```php Plugin::load('Icings/Menu'); ``` 3. Load the helper in your `AppView` class' `initialize()` method: ```php $this->loadHelper('Icings/Menu.Menu'); ``` ## Usage Detailed usage documentation can be found in the [docs](docs/index.md) 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: ```php $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: ```html ``` ### 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: ```php 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](https://github.com/icings/menu/issues) to report problems.