Symfony 2,ServiceNotFoundException,不存在的服务“templating.engine.php”

时间:2015-11-21 13:13:32

标签: php symfony service

使用命令:c:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ xshare> php app / console debug:container -vv

我收到错误:

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
  The service "makerlabs.templating.helper.pager" has a dependency on a non-existent service "templating.engine.php".

我正在效仿这个例子: http://sourceforge.net/p/p5chi-xshare/wiki/Lesson%202:%20Project%20and%20Data%20base%20structure/

文件“C:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ xshare \ src \ MakerLabs \ PagerBundle \ Resources \ config \ services.xml”有行:

<service id="makerlabs.templating.helper.pager" class="%makerlabs.templating.helper.pager.class%">
    <tag name="templating.helper" alias="pager" />
    <argument type="service" id="templating.engine.php" />
    <argument type="service" id="router" />

文件“C:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ xshare \ vendor \ symfony \ symfony \ src \ Symfony \ Bundle \ FrameworkBundle \ Resources \ config \ templating_php.xml” 有行,定义此服务:

<services>
    <service id="templating.engine.php" class="%templating.engine.php.class%" public="false">
        <argument type="service" id="templating.name_parser" />
        <argument type="service" id="service_container" />
        <argument type="service" id="templating.loader" />
        <argument type="service" id="templating.globals" />
        <call method="setCharset"><argument>%kernel.charset%</argument></call>
    </service>

因此我不明白,为什么symfony2抱怨找不到服务?如何更正此错误?

我删除了Bundle makerlabs,因为错误我无法列出服务。比我用命令列出服务: c:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ xshare&gt; php app / console debug:container&gt; “C:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ xshare \ out.txt”

列出的服务中不存在服务“templating.engine.php”。如何加载?现有服务:

 templating                                                         Symfony\Bundle\TwigBundle\TwigEngine                                                       
 templating.filename_parser                                         Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser                           
 templating.helper.assets                                           Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper                              
 templating.helper.logout_url                                       Symfony\Bundle\SecurityBundle\Templating\Helper\LogoutUrlHelper                            
 templating.helper.router                                           Symfony\Bundle\FrameworkBundle\Templating\Helper\RouterHelper                              
 templating.helper.security                                         Symfony\Bundle\SecurityBundle\Templating\Helper\SecurityHelper                             
 templating.loader                                                  Symfony\Bundle\FrameworkBundle\Templating\Loader\FilesystemLoader                          
 templating.name_parser                                             Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser                               
 test.client   

1 个答案:

答案 0 :(得分:1)

解决方案&#34; qooplmao&#34;是添加&#39; php&#39;至 C:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ todoapp \应用\配置\ config.yml

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

有效。错误未显示。但如果有人试图列出服务: c:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ xshare&gt; php app / console debug:container&gt; &#34; C:\ Bitnami \ wampstack-5.5.30-0 \ sym_prog \ xshare \ out.txt&#34;

服务&#34; templating.engine.php&#34;未列出。