5

i'm trying to get FOSOAuthServerBundle to work on my project Running symfony 3.4.0

templating seems to be missing but i can't find anything about it on google. any idea what it could be? twig is working perfectly otherwise

i've cleared the cache downgraded from 3.4.1 to 3.4.0

AuthorizeController.php >

return $this->container->get('templating')->renderResponse(
        'FOSOAuthServerBundle:Authorize:authorize.html.'.$this->container->getParameter('fos_oauth_server.template.engine'),
        array(
            'form'   => $form->createView(),
            'client' => $this->getClient(),
        )
);

this is where its crashing.

  • 2
    are you sure you have the templating service ? do you see it when you do `hp bin/console debug:container` ? – t-n-y Dec 05 '17 at 15:11
  • it appears that i don't have templating indeed.. Do you know how to get it? sorry i'm new to symfony :x – Edwin ten Brinke Dec 05 '17 at 15:13
  • I'm always a bit fascinated when these sorts of questions get asked over and over again in a short period of time. I guess that some form of credit is being earned for demonstrating the ability to create an account on sof and then to post a question. In any event: https://stackoverflow.com/questions/47641679/the-service-fos-user-mailer-has-a-dependency-on-a-non-existent-service-templa?noredirect=1#comment82246508_47641679 – Cerad Dec 05 '17 at 15:16
  • you aboslute legend! i'm very sorry for not finding the other question. i searched for hours. i need better google skills. thank you so much for the help tho guys. – Edwin ten Brinke Dec 05 '17 at 15:22
  • 2
    Here is a hint: take your error message and paste into your search bar. – Cerad Dec 05 '17 at 15:26
  • @Cerad: why no vote to close as a duplicate? – Hovercraft Full Of Eels Dec 05 '17 at 16:34
  • @EdwintenBrinke: that sort of language has no place on this site. – Hovercraft Full Of Eels Dec 05 '17 at 16:34
  • 1
    @HovercraftFullOfEels Well, strictly speaking the question I linked to does not have an actual answer. I answered it in comments. Think it needs an answer before this one could be marked as a dup. But on a lighter note, I got a chuckle of how quickly I went from an "aboslute legend" to "entitled vagina" with a penis. Really made my day. – Cerad Dec 05 '17 at 16:46
  • @Cerad: Let's just leave it at that you're a man of many talents – Hovercraft Full Of Eels Dec 05 '17 at 20:08

3 Answers3

25

I'm assuming you're using Symfony Flex, since it has this minimalist approach it doesn't come with twig, which is the default templating system for Symfony.

Please install it via:

composer require twig

In any case if you have already twig installed but it's not working, make sure your configurations has it available:

# app/config/config.yml

framework:
    # ...
    templating:
        engines: ['twig']
Renato Mefi
  • 2,131
  • 1
  • 18
  • 27
13

This issue appears to have been introduced in Symfony 3.4, as when I installed FOSUserBundle on 3.3 it was working fine.

So piggybacking on Renato Mefi's response, if Twig is working as expected, you don't even have to composer require it, just specify which templating engine your application uses in your config.yml:

framework:
    # ...
    templating:
        engines: ['twig']
1

Symfony >4.2

use Psr\Container\ContainerInterface;

public function __construct(
    ContainerInterface $container
) {
    parent::__construct();
    $this->twig = $container->get('twig');
}

then:

$this->twig->render($view, $params);
Edmunds22
  • 715
  • 9
  • 10