10

我将我的项目从 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  
4

1 回答 1

11

更新

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

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

上一个答案

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

根据此提交,此问题已在 1 月份修复

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

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

并运行composer update

对于未来的读者,您可以选择 2.4.1 之后的任何版本目前,Knplabs 还没有发布跟踪 Symfony 2.7 的版本。

此处概述的替代解决方案是添加php到您的框架模板引擎配置中:

framework:
    templating:
        engines: ['twig', 'php']
于 2015-04-13T16:11:39.647 回答