Symfony 2, ServiceNotFoundException, non-existent

2019-08-05 20:44发布

问题:

using command: c:\Bitnami\wampstack-5.5.30-0\sym_prog\xshare>php app/console debug:container -vv

I am getting an error:

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

I am following the example: http://sourceforge.net/p/p5chi-xshare/wiki/Lesson%202:%20Project%20and%20Data%20base%20structure/

File "C:\Bitnami\wampstack-5.5.30-0\sym_prog\xshare\src\MakerLabs\PagerBundle\Resources\config\services.xml" has lines:

<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" />

File "C:\Bitnami\wampstack-5.5.30-0\sym_prog\xshare\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Resources\config\templating_php.xml" has lines, where this service is defined:

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

Thus i do not understand, why symfony2 complains that service is not found? How to correct this error?


I have deleted Bundle makerlabs, because of the error i could not list services. Than i have listed services with command: c:\Bitnami\wampstack-5.5.30-0\sym_prog\xshare>php app/console debug:container > "C:\Bitnami\wampstack-5.5.30-0\sym_prog\xshare\out.txt"

Service "templating.engine.php" does not exists among listed services. How to load it? Existing services:

 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:

The solution according "qooplmao" is to add 'php' to C:\Bitnami\wampstack-5.5.30-0\sym_prog\todoapp\app\config\config.yml

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

It works. The error does not show up. But if one tries to list services: c:\Bitnami\wampstack-5.5.30-0\sym_prog\xshare>php app/console debug:container > "C:\Bitnami\wampstack-5.5.30-0\sym_prog\xshare\out.txt"

The service "templating.engine.php" is not listed.