简体   繁体   English

Symfony2错误:服务“模板”依赖于不存在的服务“ templating.globals”

[英]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; 我刚刚使用以下命令安装了一个捆绑包,以在项目中激活Mustache模板,但是现在出现以下错误;

The service "templating" has a dependency on a non-existent service "templating.globals". 服务“模板”依赖于不存在的服务“ templating.globals”。

The command I used was: 我使用的命令是:

composer.phar require bobthecow/mustache-bundle composer.phar需要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? 当然,我知道我缺少templating.globals服务,但是如何包含它,为什么不自动包含它呢?

The templating.globals service is only created by the symfony/framework-bundle if you have php in the list on templating engines. 如果您在模板引擎列表中有php ,则templating.globals服务仅由symfony/framework-bundle创建。

As you can see in the Resources/config/templating_php.xml the service is created. 如您在Resources/config/templating_php.xml看到的那样,该服务已创建。

This file is only loaded in the extension if php is in the list of templating engines . 如果php在模板引擎列表中,则仅在扩展名中加载此文件。

TL;DR Add php to the templating engines in your app/config/config.yml . TL; DRphp添加到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: 如果您正在运行Symfony 4.x,则必须将以下内容添加到config / packages / framework.yaml中:

framework:
    # ... other stuff ...

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 服务“sonata.block.service.container”依赖于不存在的服务“模板化” - The service “sonata.block.service.container” has a dependency on a non-existent service “templating” Symfony 2,ServiceNotFoundException,不存在的服务“ templating.engine.php” - Symfony 2, ServiceNotFoundException, non-existent service “templating.engine.php” 您请求了一个不存在的服务“模板” - You have requested a non-existent service "templating" 升级到2.7后,您已请求不存在的服务“ templating.helper.form” - You have requested a non-existent service “templating.helper.form” after upgrading to 2.7 Symfony 3.4 - 服务“Symfony\\Component\\Ldap\\Ldap”依赖于不存在的服务“Symfony\\Component\\Ldap\\Adapter\\ExtLdap\\Adapter” - Symfony 3.4 - The service "Symfony\Component\Ldap\Ldap" has a dependency on a non-existent service "Symfony\Component\Ldap\Adapter\ExtLdap\Adapter" Symfony:服务...依赖于不存在的参数kernel.secret - Symfony: The service … has a dependency on a non-existent parameter kernel.secret 服务“App\Decorator\DomainHydraDecorator”依赖于一个不存在的服务“api_platform.hydra.normalizer.error” - The service "App\Decorator\DomainHydraDecorator" has a dependency on a non-existent service "api_platform.hydra.normalizer.error" Symfony突然失败,“服务”session.storage.metadata_bag“依赖于不存在的参数” - Symfony is suddenly failing with “The service ”session.storage.metadata_bag“ has a dependency on a non-existent parameter” Symfony 3.4-服务“ AppBundle \\ Controller \\ [some] Controller”依赖于不存在的服务“ Symfony \\ Component \\ Serializer \\ Serializer” - Symfony 3.4 - The service “AppBundle\Controller\[some]Controller” has a dependency on a non-existent service “Symfony\Component\Serializer\Serializer” 自symfony 3.3以来不存在的服务错误 - Non-existent service error since symfony 3.3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM