Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8122737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T05:55:37+00:00 2026-06-06T05:55:37+00:00

The KNP MenuBundle is a Symfony2 bundle for handling menus in a very dynamic

  • 0

The KNP MenuBundle is a Symfony2 bundle for handling menus in a very dynamic way. The bundle comes out with a simple tutorial example, provided here.
In the proposed example, within the Builder class, the authors supposed that a function setCurrentUri() has to be called on the $menu object. However, $menu is an instance of MenuItem class, which does not implements the above mentioned function.

To make the answer self contained, I report the code of the example class provided here:

<?php
// src/Acme/DemoBundle/Menu/Builder.php
namespace Acme\DemoBundle\Menu;

use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;

class Builder extends ContainerAware
{
    public function mainMenu(FactoryInterface $factory, array $options)
    {
        $menu = $factory->createItem('root');
        $menu->setCurrentUri($this->container->get('request')->getRequestUri());

        $menu->addChild('Home', array('route' => 'homepage'));
        $menu->addChild('About Me', array(
            'route' => 'page_show',
            'routeParameters' => array('id' => 42)
        ));
        // ... add more children

        return $menu;
    }
}

PS: Notice that an important import is missing in this example, which I report in the following for sake of completeness:

use Symfony\Component\HttpFoundation\Request;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T05:55:39+00:00Added an answer on June 6, 2026 at 5:55 am

    I am also looking for the documentation update, but as a temporary solution you can set versions in deps like these:

    [KnpMenu]
        git=https://github.com/KnpLabs/KnpMenu.git
        version=v1.1.2
    
    [KnpMenuBundle]
        git=https://github.com/KnpLabs/KnpMenuBundle.git
        target=/bundles/Knp/Bundle/MenuBundle
        version=v1.1.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I learn Symfony 2. I would like have example with SonataAdminBundle. I found: http://sonata-project.org/bundles/news/2-0/doc/reference/installation.html
How to customize KNPMenuBundle? I can't figure out how to add an image or
i made a new bundle, made a new controller made few entities entity does
Let's say I have an numpy array A of size n x m x
I am running Symfony 2.0.6, and I get the following error: InvalidArgumentException: There is
Does anyone know if it is possible to use an image generated with KnpSnappyBundle
I'm using the KnpMenuBundle in my application, and I have followed their instructions to
I'm transferring my project from the laptop to a test/production server. I'm copying the
I have 1 controller that passes 2 paginated set of results to a twig
I'm getting the following error while running Snappy, a PHP binding for WKHTMLTOPDF: Fatal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.