Edwin ten Brinke
Edwin ten Brinke

Reputation: 79

You have requested a non-existent service "templating"

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.

Upvotes: 5

Views: 8858

Answers (3)

Edmunds22
Edmunds22

Reputation: 791

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);

Upvotes: 1

Sylvester Saracevas
Sylvester Saracevas

Reputation: 316

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']

Upvotes: 13

Renato Mefi
Renato Mefi

Reputation: 2171

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']

Upvotes: 25

Related Questions