1

I try use knpMenuBundle in symfony 4

I render {{ knp_menu_render('App:MenuBuilder:menuTags') }}

class is in src/ App\Menu\MenuBuilder

get

An exception has been thrown during the rendering of a template ("Bundle "App" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your App\Kernel.php file?").

Second i try use it as service -

{{ knp_menu_render('App\Menu\Builder:menuTags') }}

dont work...

i can inject this auto register service to other controller .

i read in packagist -

KnpMenuBundle v2.2.1
require:
symfony/framework-bundle: ~2.7|~3.0 | ^4.0

so it should work - in official symfony Documentation any information about symfony 4

https://symfony.com/doc/master/bundles/KnpMenuBundle/menu_service.html

I think remove APpBundle was a stupid way...

Any idea how i can use MenuBuilder ?

Developer
  • 2,731
  • 2
  • 41
  • 71

1 Answers1

2

You can not use this "{{knp_menu_render ('App \ Menu \ Builder: menuTags')}}" to service. Use the alias of the service you created.

With Symfony 4 you need to use the menus as a service.

Try it out.

{{ knp_menu_render ('main') }}
Cesur APAYDIN
  • 806
  • 3
  • 11
  • 24
  • It's a shame, but I understand - maybe in symfony 5 we get back AppBundle or similar links - like app:class:method now phpstorm dont understand {{ knp_menu_render ('main') }} and main is not link – Developer May 29 '18 at 10:45
  • I wrote a simple and handy menu system for Symfony 4. I advise you to review. https://github.com/rmznpydn/pd-menu – Cesur APAYDIN May 29 '18 at 23:14