我有一个控制器,让我们说 Acme\ShopBundle\Controller\ProductListController其定义services.yml如下:services: Acme\ShopBundle\Controller\ProductListController: class: Acme\ShopBundle\Controller\ProductListController arguments: ['@product_service']这在我的日志文件中抛出:User Deprecated: The "Acme\ShopBundle\Controller\ProductListController" service is private, checking for its existence is deprecated since Symfony 3.2 and will fail in 4.0.其次是User Deprecated: The "Acme\ShopBundle\Controller\ProductListController" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.文件的堆栈跟踪列表完全在里面,vendor/symfony所以我假设某些东西配置错误,但不知道是什么。任何帮助表示赞赏。
1 回答
回首忆惘然
TA贡献1847条经验 获得超11个赞
控制器服务必须是公开的:
services:
Acme\ShopBundle\Controller\ProductListController:
public: true
arguments: ['@product_service']
你为什么不使用自动装配呢?然后您可以注册所有控制器:
Acme\ShopBundle\Controller\:
resource: '../src/Acme/ShopBundle/Controller' # mutatis mutandis
tags: ['controller.service_arguments']
请阅读有关 Symfony 3 中依赖项管理的新功能。
- 1 回答
- 0 关注
- 169 浏览
添加回答
举报
0/150
提交
取消