Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony exception KNPMenu builder does not exist for menu builder
    text
    copied!<p>I try the KnpMenu tutorial to create a menu, and use it with bootstrap in Symfony. It works perfectly in local mode, but when I try it on my server (both in dev mode) it don't works, I have this error :</p> <blockquote> <p>An exception has been thrown during the rendering of a template ("Class "robStorm\WelcomeBundle\Menu\Builder" does not exist for menu builder "robStormWelcomeBundle:Builder".") in "robStormWelcomeBundle:Homepage:index.html.twig". 500 Internal Server Error - Twig_Error_Runtime 1 linked Exception: InvalidArgumentException »</p> </blockquote> <p>However, I have exactly the same files in local or on the server...</p> <p>Here is the content of my file :</p> <p>In app/config/config.yml :</p> <pre><code># Twig Configuration twig: debug: %kernel.debug% strict_variables: %kernel.debug% twig: form: resources: - "BraincraftedBootstrapBundle:Form:form_div_layout.html.twig" knp_menu: twig: template: "BraincraftedBootstrapBundle:Menu:menu.html.twig" </code></pre> <p>In src/robStorm/WelcomeBundle/Controller/HomepageController :</p> <pre><code>public function indexAction() { return $this-&gt;render('robStormWelcomeBundle:Homepage:index.html.twig'); } </code></pre> <p>In src/robStorm/WelcomeBundle/Menu/builder.php :</p> <pre><code>&lt;?php namespace robStorm\WelcomeBundle\Menu; use Knp\Menu\FactoryInterface; use Symfony\Component\DependencyInjection\ContainerAware; use Knp\Menu\Matcher\Matcher; use Knp\Menu\Matcher\Voter\UriVoter; use Knp\Menu\MenuFactory; use Knp\Menu\Renderer\ListRenderer; class Builder extends ContainerAware { public function mainMenu(FactoryInterface $factory, array $options) { $menu = $factory-&gt;createItem('root'); $item = $menu-&gt;addChild('Accueil', array('route' =&gt; 'robStormWelcomeBundle_homepage')); $menu-&gt;addChild('Combat', array('route' =&gt; 'robStormWelcomeBundle_homepage_combat')); $menu-&gt;addChild('Boutique', array('uri' =&gt; '#')); return $menu; } public function menuDroite(FactoryInterface $factory, array $options) { $menu = $factory-&gt;createItem('root'); $menu-&gt;addChild('Aide', array('uri' =&gt; '#')); $menu-&gt;addChild('d1', array('attributes' =&gt; array('divider' =&gt; true))); $dropdown = $menu-&gt;addChild('Mon compte'); $dropdown-&gt;addChild('Mon profil', array('uri' =&gt; '#')); $dropdown-&gt;addChild('Mes messages', array('uri' =&gt; '#')); $dropdown-&gt;addChild('d1', array('attributes' =&gt; array('divider' =&gt; true))); $dropdown-&gt;addChild('Se déconnecter', array('uri' =&gt; '#')); return $menu; } } </code></pre> <p>In src/robStorm/WelcomeBundle/Ressources/config/routing.yml :</p> <pre><code>robStormWelcomeBundle_homepage: pattern: / defaults: { _controller: "robStormWelcomeBundle:Homepage:index" } </code></pre> <p>In src/robStorm/WelcomeBundle/Ressources/views/layout.html.twig :</p> <pre><code>&lt;div class="container"&gt; {{ knp_menu_render('robStormWelcomeBundle:Builder:mainMenu', {'nav_type': 'navbar', 'currentAsLink': true}) }} {{ knp_menu_render('robStormWelcomeBundle:Builder:menuDroite', {'nav_type': 'navbar', 'currentAsLink': true, 'pull': 'right'}) }} &lt;/div&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload