我下载了 Symfony (3.3.3) 的最新稳定版本,但在启动时出现错误:
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 Controller 扩展
Symfony\Bundle\FrameworkBundle\Controller\Controller.php
现在扩展:
Symfony\Bundle\FrameworkBundle\Controller\AbstractController\AbstractController.php
那么...我怎样才能从容器中获取数据呢?在文档(3.3 和 4.0 版本)中,Controller 扩展了 Controller,而不是 AbstractController。
如果我将 AbstractController 更改为 Controller 应用程序运行良好,但我是否应该进行此更改?
最佳答案
他们已经reverted the change在 symfony 标准版上,所以我会说回到 Controller
而不是 AbstractController
是要走的路。
关于php - Symfony 3.3.3 - 默认 Controller 和容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44904806/