Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/desarrolla2/menubundle
https://github.com/desarrolla2/menubundle
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/desarrolla2/menubundle
- Owner: desarrolla2
- License: mit
- Created: 2017-02-25T10:19:52.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-08-31T20:25:54.000Z (over 3 years ago)
- Last Synced: 2024-11-22T16:47:00.714Z (about 1 month ago)
- Language: PHP
- Size: 22.5 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
MenuBundle
=============The `MenuBundle` means easy-to-implement and feature-rich menus in your Symfony application!
## Installation
### Download the Bundle
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:```bash
$ composer require desarrolla2/menu-bundle
```
This command requires you to have Composer installed globally, as explained
in the `installation chapter` of the Composer documentation.### Enable the Bundle
Then, enable the bundle by adding the following line in the ``app/AppKernel.php``
file of your project:```php
// app/AppKernel.php// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...new Knp\Bundle\Desarrolla2\MenuBundle(),
);// ...
}// ...
}
```
## Create your first menuAn example builder class would look like this:
```php
'sidebar-menu',
'items' => [
[
'name' => 'Users',
'icon' => 'fa fa-user',
'items' => [
[
'name' => 'Admins',
'route' => 'admin_core_user_admin_list',
'active_routes' => [
'admin_core_user_admin_[\w]+',
],
],
[
'name' => 'Clients',
'route' => 'admin_core_user_client_list',
'active_routes' => [
'admin_core_user_client_[\w]+',
],
],
],
],
[
'name' => 'Groups',
'route' => 'admin_core_group_list',
'icon' => 'fa fa-users',
'active_routes' => [
'admin_core_group_[\w]+',
'_admin.group.[\w\.]',
],
],
],
];
}
}
```## Render
To actually render the menu, just do the following from anywhere in any template:
```html+jinja
{{ renderMenu('TeacherBundle\\Menu\\MainMenu','sidebar') }}
```If you are defined your menu as a service, you can render as follow:
```html+jinja
{{ renderMenu('my.menu.service.name','sidebar') }}
```