Symfony 3.3.3 - 默认控制器和容器 [英] Symfony 3.3.3 - default controller and container
问题描述
我下载了 Symfony 的最新稳定版本 (3.3.3),但在启动时出现错误:
I downloaded last stable version of Symfony (3.3.3) and on start I have error:
Attempted to call an undefined method named "getParameter" of class "AppBundle\Controller\DefaultController".
这是:
'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
3.3.3 之前的 Symfony 控制器扩展
Before 3.3.3 version Symfony controllers extended
Symfony\Bundle\FrameworkBundle\Controller\Controller.php
Symfony\Bundle\FrameworkBundle\Controller\Controller.php
现在扩展:
Symfony\Bundle\FrameworkBundle\Controller\AbstractController\AbstractController.php
Symfony\Bundle\FrameworkBundle\Controller\AbstractController\AbstractController.php
那么...如何从容器中获取数据?在文档(3.3 和 4.0 版本)中,Controller 扩展了 Controller,而不是 AbstractController.
So... How can I get data from container? In documentation (3.3 and 4.0 versions) Controller extends Controller, not AbstractController.
如果我将 AbstractController 更改为 Controller 应用程序运行良好,但我应该更改吗?
If I change AbstractController to Controller application works well, but do I should this change?
推荐答案
他们已经reverted the change on the symfony standard edition 所以我会说回到 Controller
而不是 AbstractController
是要走的路.
They have already reverted the change on the symfony standard edition so I would say that going back to Controller
instead of AbstractController
is the way to go.
这篇关于Symfony 3.3.3 - 默认控制器和容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!