Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Menu Bundle Laravel Package

disjfa/menu-bundle

View on GitHub
Deep Wiki
Context7

Menu bundle

Check on packagist MIT License

Watch on GitHub Star on GitHub Tweet

What does it do

This bundle adds two menu builders for your project. One for the site side, and one for the admin. This can help it to make live easier to generate menu structures. You can take a look at glynn-admin-symfony4 for a simple working example. It is using the KnpMenuBundle.

It is opinionated, it is setup using the bootstrap4 template

Instalation

composer req disjfa/menu-bundle

Setup

In the template you have to add a menu.

{{ knp_menu_render('admin', {'currentClass': 'active', 'ancestorClass': 'active', 'depth':3, 'template': 'admin/menu.html.twig'}) }}

or

{{ knp_menu_render('site', {'currentClass': 'active', 'ancestorClass': 'active', 'depth':2, 'template': 'admin/menu.html.twig'}) }}

Resister a menu

And then, in your code you can just subscribe to the menus to add your own

<?php

namespace App\Menu;

use Disjfa\MenuBundle\Menu\ConfigureSiteMenu;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class MenuListener implements EventSubscriberInterface
{
    public function onMenuConfigure(ConfigureSiteMenu $event)
    {
        $menu = $event->getMenu();

        $menu->addChild('my_route', [
            'route' => 'my_route',
            'label' => 'My route title',
        ])->setExtra('icon', 'fa-home');
    }

    /**
     * @return array
     */
    public static function getSubscribedEvents()
    {
        return [
            ConfigureSiteMenu::class => ['onMenuConfigure', 999]
        ];
    }
}

Or you can subscribe to the ConfigureAdminMenu event to do the same for the admin menu.

And done

And now we are done. Make menus, be awesome!

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
iio/libmergepdf
redaxo/project
zatona-eg/zatona-eg-api
patrickbussmann/oauth2-apple
3brs/enterprise-security-bundle
ardenexal/fhir-models
ardenexal/fhir-validation
dpfx/laravel-livewire-wizards
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle
dmstr/api-platform-utils-bundle
dmstr/api-configuration-bundle
chrisdev/ux-components
crudly/encrypted
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony