在symfony 2.7中找不到'templating.helper.router'服务

时间:2015-04-13 12:02:39

标签: symfony knppaginator symfony-2.7

我将我的项目从2.6升级到2.7,我在工作结束时得到这个错误:

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]                                           
The service "knp_paginator.helper.processor" has a dependency on a non-existent service "templating.helper.router". 

我搜索服务容器,但我找不到服务列表中的服务(容器:调试),我找到了" templating.helper.router"的服务定义。在这个文件

/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml

为什么服务不是由服务容器创建的?


     /usr/bin/php /var/www/ghanbari/anar/app/console debug:container --tag=templating.helper -v

Deprecated: The Symfony\Component\DependencyInjection\Definition::setFactoryMethod method is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. in /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php on line 137

Call Stack:
    0.0004     227656   1. {main}() /var/www/ghanbari/anar/app/console:0
    0.0161    2719288   2. Symfony\Component\Console\Application->run() /var/www/ghanbari/anar/app/console:27
    0.0178    2896416   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
    0.0178    2896640   4. Symfony\Component\HttpKernel\Kernel->boot() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70
    0.0210    3132184   5. Symfony\Component\HttpKernel\Kernel->initializeContainer() /var/www/ghanbari/anar/app/bootstrap.php.cache:2387
    0.0801    6683560   6. Symfony\Component\DependencyInjection\ContainerBuilder->compile() /var/www/ghanbari/anar/app/bootstrap.php.cache:2609
    0.0806    6716880   7. Symfony\Component\DependencyInjection\Compiler\Compiler->compile() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:614
    0.0806    6725096   8. Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass->process() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:117
    0.0808    6730560   9. Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass->process() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php:39
    0.2364   13801624  10. FOS\UserBundle\DependencyInjection\FOSUserExtension->load() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php:55
    0.2388   14110096  11. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->load() /var/www/ghanbari/anar/vendor/friendsofsymfony/user-bundle/DependencyInjection/FOSUserExtension.php:32
    0.2397   14111016  12. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->parseDefinitions() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php:58
    0.2399   14115360  13. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->parseDefinition() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php:119
    0.2399   14118016  14. Symfony\Component\DependencyInjection\Definition->setFactoryMethod() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php:153
    0.2399   14118352  15. trigger_error() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php:137


Deprecated: The Symfony\Component\DependencyInjection\Definition::setFactoryService method is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. in /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php on line 208

Call Stack:
    0.0004     227656   1. {main}() /var/www/ghanbari/anar/app/console:0
    0.0161    2719288   2. Symfony\Component\Console\Application->run() /var/www/ghanbari/anar/app/console:27
    0.0178    2896416   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:126
    0.0178    2896640   4. Symfony\Component\HttpKernel\Kernel->boot() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70
    0.0210    3132184   5. Symfony\Component\HttpKernel\Kernel->initializeContainer() /var/www/ghanbari/anar/app/bootstrap.php.cache:2387
    0.0801    6683560   6. Symfony\Component\DependencyInjection\ContainerBuilder->compile() /var/www/ghanbari/anar/app/bootstrap.php.cache:2609
    0.0806    6716880   7. Symfony\Component\DependencyInjection\Compiler\Compiler->compile() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php:614
    0.0806    6725096   8. Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass->process() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php:117
    0.0808    6730560   9. Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass->process() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php:39
    0.2364   13801624  10. FOS\UserBundle\DependencyInjection\FOSUserExtension->load() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php:55
    0.2388   14110096  11. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->load() /var/www/ghanbari/anar/vendor/friendsofsymfony/user-bundle/DependencyInjection/FOSUserExtension.php:32
    0.2397   14111016  12. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->parseDefinitions() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php:58
    0.2399   14115360  13. Symfony\Component\DependencyInjection\Loader\XmlFileLoader->parseDefinition() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php:119
    0.2404   14118448  14. Symfony\Component\DependencyInjection\Definition->setFactoryService() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php:153
    0.2404   14118792  15. trigger_error() /var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php:208

[2015-04-13 20:34:41] php.INFO: The Symfony\Component\DependencyInjection\Definition::setFactoryMethod method is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. {"type":16384,"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php","line":137,"level":-1,"stack":[{"function":"handleError","class":"Symfony\\Component\\Debug\\ErrorHandler","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php","line":137,"function":"trigger_error"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php","line":153,"function":"setFactoryMethod","class":"Symfony\\Component\\DependencyInjection\\Definition","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php","line":119,"function":"parseDefinition","class":"Symfony\\Component\\DependencyInjection\\Loader\\XmlFileLoader","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php","line":58,"function":"parseDefinitions","class":"Symfony\\Component\\DependencyInjection\\Loader\\XmlFileLoader","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php","line":184,"function":"load","class":"Symfony\\Component\\DependencyInjection\\Loader\\XmlFileLoader","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php","line":113,"function":"getContainerBuilder","class":"Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerDebugCommand","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php","line":259,"function":"execute","class":"Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerDebugCommand","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php","line":886,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php","line":195,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php","line":96,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php","line":126,"function":"doRun","class":"Symfony\\Bundle\\FrameworkBundle\\Console\\Application","type":"->"},{"file":"/var/www/ghanbari/anar/app/console","line":27,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"}]} 
[2015-04-13 20:34:41] php.INFO: The Symfony\Component\DependencyInjection\Definition::setFactoryService method is deprecated since version 2.6 and will be removed in 3.0. Use Definition::setFactory() instead. {"type":16384,"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php","line":208,"level":-1,"stack":[{"function":"handleError","class":"Symfony\\Component\\Debug\\ErrorHandler","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Definition.php","line":208,"function":"trigger_error"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php","line":153,"function":"setFactoryService","class":"Symfony\\Component\\DependencyInjection\\Definition","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php","line":119,"function":"parseDefinition","class":"Symfony\\Component\\DependencyInjection\\Loader\\XmlFileLoader","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php","line":58,"function":"parseDefinitions","class":"Symfony\\Component\\DependencyInjection\\Loader\\XmlFileLoader","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php","line":184,"function":"load","class":"Symfony\\Component\\DependencyInjection\\Loader\\XmlFileLoader","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php","line":113,"function":"getContainerBuilder","class":"Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerDebugCommand","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php","line":259,"function":"execute","class":"Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerDebugCommand","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php","line":886,"function":"run","class":"Symfony\\Component\\Console\\Command\\Command","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php","line":195,"function":"doRunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php","line":96,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/ghanbari/anar/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php","line":126,"function":"doRun","class":"Symfony\\Bundle\\FrameworkBundle\\Console\\Application","type":"->"},{"file":"/var/www/ghanbari/anar/app/console","line":27,"function":"run","class":"Symfony\\Component\\Console\\Application","type":"->"}]} 
[container] Public services with tag templating.helper
 Service ID                   alias      Class name                                                      
 templating.helper.assets     assets     Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper   
 templating.helper.logout_url logout_url Symfony\Bundle\SecurityBundle\Templating\Helper\LogoutUrlHelper 
 templating.helper.security   security   Symfony\Bundle\SecurityBundle\Templating\Helper\SecurityHelper  

1 个答案:

答案 0 :(得分:11)

更新

KnpPaginator的新2.4.2版本将解决此问题。您的composer.json文件应如下所示:

"knplabs/knp-paginator-bundle": "~2.4"

上一个回答

如果您要使用最新版本的Symfony,请确保您在项目中使用所需捆绑包的最新版本并运行composer update。您甚至可能需要使用dev-master版本。

This problem was fixed in January as per this commit

对于此特定问题,请更新您的composer.json文件以获取此行:

"knplabs/knp-paginator-bundle": "2.4.*@dev"

并运行composer update

对于未来的读者,您可以pick any version later than 2.4.1目前,Knplabs尚未发布跟踪Symfony 2.7的版本。

outlined here的替代解决方案是将php添加到框架模板引擎配置中:

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