menu-bundle is a symfony bundle to display a menu according to the configuration stored in menu.yaml. routes stored under path and known to the system are recognized and displayed as "active", if this page is currently active. labels of the menu items are translated if they are stored in the translations.
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
$ composer require byte-artist/menu-bundle
Open a command console, enter your project directory and execute the following command to install the latest stable version of this bundle:
$ composer require byte-artist/menu-bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php file of your project:
// config/bundles.php
return [
// ...
ByteArtist\MenuBundle\MenuBundle::class => ['all' => true],
];
Example:
menu:
type: default
brand_name: Brand Name
use_orig_css: true
use_orig_js: true
pages:
label_home:
path: existing_route
label_user:
path: label_user_index
pages:
label_user_create:
path: route_user_create
label_user_edit:
path: route_user_edit
label_admin:
path: #
pages:
label_admin_overview:
path: route_admin_index
label_admin_edit:
path: route_admin_edit
label_contact:
path: route_content
label_imprint: https://www.byte-artist.de/imprint
route_name: name of the menu item, if it exists in the translations it will be translated, otherwise the item will just be displayed as specified here
[
]
To display the menu, it is sufficient to call the Twig function menu in a Twig template, wherever it is to be displayed:
// layout.html.twig
{{ menu() }}
if for some reason the symfony repository for the contrib recipes is not available, add the following lines in your composer.json:
"extra": {
"symfony": {
"endpoint": [
"https://api.github.com/repos/mastercad/symfony-recipes/contents/index.json",
"flex://defaults"
]
}
}
How can I help you explore Laravel packages today?