Symfony 5.0 and KnpMenuBundle – how to configure

In a Symfony 5.0 Application I want to use the KnpMenuBundle.
I installed it by running

composer require knplabs/knp-menu-bundle "^3.0"

This automatically created an entry in [ProjectRoot]/config/bundles.php”:

KnpBundleMenuBundleKnpMenuBundle::class => ['all' => true]

Of course it downloaded the bundle as well.

The documentation (found at: https://symfony.com/doc/master/bundles/KnpMenuBundle/index.html) states to configure the bundle one should edit the file “app/config/config.yml”. Symfony 5 does not have this file anymore – but single config files for each “package” in “[ProjectRoot]/config/packages”.
However there wasn’t a config file created for KnpMenuBundle. How could I do this myself – meaning: Whats the naming conventions and how do I tell the bundle to actualy use the config file?

There is another issue.
In the documentation it says rendering a Menu in a twig template works like this:

{{ knp_menu_render('AppBundle:Builder:mainMenu') }}

For Symfony 5 – what would be the right syntax / path there?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *