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

4
  • 1
    Possible duplicate of How to insert a Controller in Twig with "render" in Symfony 2.2? Commented Nov 25, 2015 at 7:01
  • Could you post the error message as well? Commented Nov 25, 2015 at 8:05
  • hey frd thnx for support but i found a solution render(controller('AppBundle:front\\Menus:menuAll')) Commented Nov 25, 2015 at 8:17
  • Just for info, a single forward slash will work in place of two back slashes. Commented Nov 25, 2015 at 14:27

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

1 Comment

yes you are right but my controller in front folder look this path (\src\AppBundle\Controller\front\MenusController.php)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.