user5500750
user5500750

Reputation:

Symfony2 error: The service "templating" has a dependency on a non-existent service "templating.globals"

I have just installed a bundle using the following command to activate Mustache templates in my project but now I get the following error;

The service "templating" has a dependency on a non-existent service "templating.globals".

The command I used was:

composer.phar require bobthecow/mustache-bundle

Of course I know I am missing the templating.globals service but How do I include this and why is it not included automatically?

Upvotes: 8

Views: 8691

Answers (2)

Siddiqui Noor
Siddiqui Noor

Reputation: 8036

If you are running Symfony 4.x then You've to add the following to the config/packages/framework.yaml:

framework:
    # ... other stuff ...

    templating:
        engines: ['twig', 'php']

Upvotes: 1

qooplmao
qooplmao

Reputation: 17759

The templating.globals service is only created by the symfony/framework-bundle if you have php in the list on templating engines.

As you can see in the Resources/config/templating_php.xml the service is created.

This file is only loaded in the extension if php is in the list of templating engines.

TL;DR Add php to the templating engines in your app/config/config.yml.

# app/config/config.yml
framework:
    # ...
    templating:
        engines: ['twig', 'php']

Upvotes: 27

Related Questions