gpt4 book ai didi

mysql - Symfony 3.4 getDoctrine() 导致错误

转载 作者:行者123 更新时间:2023-11-29 17:38:59 27 4
gpt4 key购买 nike

我看过一些关于这个主题的帖子,但没有找到我正在寻找的答案。当我从一个方法调用 $this->getDoctrine(); 时,说 public function returnObjectAction(){} 并且该类实现 use Symfony\Bundle\FrameworkBundle\Controller\Controller 它导致容器== 0。我也尝试了$this->getDoctrine()->getManager();,这也以错误“内部服务器错误。服务器遇到内部错误或配置错误,无法完成您的请求。”引用:https://symfony.com/doc/3.4/doctrine.html#fetching-objects-from-the-database

谢谢。

enter image description here

最佳答案

检查您的 Controller 是否扩展了 Controller (除了 use 之外),如下所示:

class YourController extends Controller {}

并且您的composer.json的require部分中有doctrine/ormdoctrine/doctrine-bundle

如果缺少,请添加它们。

运行composer安装

关于mysql - Symfony 3.4 getDoctrine() 导致错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50102705/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com