简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM