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

Bigfoot Navigation Bundle Laravel Package

7rin0/bigfoot-navigation-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

First Steps

  1. Installation Add the bundle to your composer.json:

    composer require 7rin0/bigfoot-navigation-bundle
    

    Enable it in config/bundles.php:

    return [
        // ...
        SevenRin0\BigfootNavigationBundle\SevenRin0BigfootNavigationBundle::class => ['all' => true],
    ];
    
  2. Basic Configuration Configure the bundle in config/packages/bigfoot_navigation.yaml:

    seven_rin0_bigfoot_navigation:
        theme: 'default'  # or your custom theme
        menu_items: []    # Define your menu structure here
    
  3. First Use Case: Rendering a Menu Use the bigfoot_navigation Twig function in your templates:

    {{ bigfoot_navigation('main_menu') }}
    

    Ensure you’ve defined main_menu in your config.


Implementation Patterns

1. Menu Structure Definition

Define menus in YAML (e.g., config/packages/bigfoot_navigation.yaml):

seven_rin0_bigfoot_navigation:
    menus:
        main_menu:
            items:
                - label: 'Home'
                  uri: '/'
                  active: true
                - label: 'About'
                  uri: '/about'
                  children:
                      - label: 'Team'
                        uri: '/about/team'

2. Dynamic Menu Items via Services

Inject the NavigationManager service to build menus programmatically:

// src/Service/MenuBuilder.php
use SevenRin0\BigfootNavigationBundle\Manager\NavigationManager;

class MenuBuilder
{
    public function __construct(private NavigationManager $navigationManager) {}

    public function buildAdminMenu(): array
    {
        return [
            'items' => [
                ['label' => 'Dashboard', 'uri' => '/admin'],
                ['label' => 'Users', 'uri' => '/admin/users'],
            ],
        ];
    }
}

Register the menu in a compiler pass or config.

3. Theming and Templates

Override default templates by copying them from: vendor/sevenrin0/bigfoot-navigation-bundle/Resources/views/ to: templates/bundles/bigfootnavigation/.

Customize Twig templates (e.g., menu.html.twig) to match your design.

4. Active Item Detection

Use the active flag in menu items or leverage Twig’s is_active logic:

{% for item in menu.items %}
    <li class="{{ 'active' if app.request.get('_route') == item.uri|route }}">{{ item.label }}</li>
{% endfor %}

5. Integration with Symfony Router

Pass route names instead of URIs for dynamic path generation:

items:
    - label: 'Products'
      route: 'app_product_index'

Gotchas and Tips

Pitfalls

  1. Symfony 3 Only This bundle is Symfony 3.x-only. Avoid using it in Symfony 4+ without compatibility checks.

  2. YAML Configuration Overrides If menus don’t render, verify:

    • The theme key in config matches an existing theme (default or custom).
    • Menu items are nested under menus: (not menu_items: in older versions).
  3. Twig Function Scope bigfoot_navigation() requires a registered menu name. Undefined names throw Twig\Error\RuntimeError.

  4. Caching Issues Clear cache after config changes:

    php bin/console cache:clear
    

Debugging Tips

  • Dump Menu Structure Use Twig’s dump() to inspect the rendered menu:
    {{ dump(bigfoot_navigation('main_menu')) }}
    
  • Check Compiled Config Run:
    php bin/console debug:config seven_rin0_bigfoot_navigation
    
    to verify loaded menus.

Extension Points

  1. Custom Themes Extend the default theme by copying Resources/public/ assets to your project’s web/ and updating the theme config.

  2. Event Listeners Subscribe to bigfoot.navigation.build events to modify menus dynamically:

    // src/EventListener/MenuModifier.php
    use SevenRin0\BigfootNavigationBundle\Event\MenuEvent;
    
    class MenuModifier implements EventSubscriber
    {
        public static function getSubscribedEvents(): array
        {
            return [MenuEvent::BUILD => 'onBuildMenu'];
        }
    
        public function onBuildMenu(MenuEvent $event): void
        {
            $event->getMenu()->addItem(['label' => 'Dynamic Item', 'uri' => '/dynamic']);
        }
    }
    
  3. Database-Driven Menus Fetch menu items from a database in a compiler pass and merge them into the config:

    // src/DependencyInjection/Compiler/DynamicMenuPass.php
    use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
    use Symfony\Component\DependencyInjection\ContainerBuilder;
    
    class DynamicMenuPass implements CompilerPassInterface
    {
        public function process(ContainerBuilder $container): void
        {
            $menuItems = $this->fetchFromDatabase();
            $container->getDefinition('bigfoot_navigation.manager')
                ->addMethodCall('setDynamicItems', [$menuItems]);
        }
    }
    

Performance

  • Avoid Over-Fetching Lazy-load menu items if the menu is large (e.g., via AJAX or Doctrine’s DISTINCT queries).
  • Cache Menus Use Symfony’s cache system to store compiled menus if they rarely change.
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony