2

i try call controller function in twig file with render but it give error this is my controller code this is controller path

\src\AppBundle\Controller\front\MenusController.php

MenusController.php Code

<?php

 namespace AppBundle\Controller\front;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
 use Symfony\Component\HttpFoundation\Request;

 class MenusController extends Controller
 {

      public function menuAllAction()
      {
          return $this->render('front/menus.html.twig');
      }
 }

and this code is my twig file code master.html.twig

{% render(controller('AppBundle:front:Menus:menuAll')) %}

but is return error please help me

jay
  • 134
  • 1
  • 11
  • 1
    Possible duplicate of [How to insert a Controller in Twig with "render" in Symfony 2.2?](http://stackoverflow.com/questions/15221230/how-to-insert-a-controller-in-twig-with-render-in-symfony-2-2) – Sergio Ivanuzzo Nov 25 '15 at 07:01
  • Could you post the error message as well? – jahller Nov 25 '15 at 08:05
  • hey frd thnx for support but i found a solution `render(controller('AppBundle:front\\Menus:menuAll'))` – jay Nov 25 '15 at 08:17
  • Just for info, a single forward slash will work in place of two back slashes. – Cerad Nov 25 '15 at 14:27

1 Answers1

2

Try like to replace {% %} by {{ }}:

{{ render(controller('AppBundle:front:Menus:menuAll')) }}

Edit:

{{ render(controller('AppBundle:Menus:menuAll')) }}

(the right synthax is: bundle:controller:action)

scoolnico
  • 3,055
  • 14
  • 24
  • yes you are right but my controller in front folder look this path (\src\AppBundle\Controller\front\MenusController.php) – jay Nov 25 '15 at 07:05