Symfony 学说错误“DoctrineMigrationsBundle 需要启用 DoctrineBundle。”

问题描述 投票:0回答:2

我创建了一个新的 Symfony 项目,并且不断收到此消息“DoctrineMigrationsBundle 需要启用 DoctrineBundle”。错误并且无法摆脱它。显然我是这个星球上唯一遇到此错误的人,因为谷歌并没有太大帮助。

在 config/bundles.php 文件中,我有以下内容应该“启用”DoctrineBundle,但我丢失了一些东西并且无法告诉它是什么。

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
];
php symfony doctrine-orm doctrine
2个回答
0
投票

我也有同样的错误, 由于某种原因,应该在

config/packages
内的 yaml 文件没有提交到 git。

您可以执行以下操作:

  • 创建一个新的 symfony 项目
  • 将 config/packages 文件夹从全新安装复制到我的项目
  • 如果也丢失了
    /bin
    文件夹,请复制它
  • 将这两行添加到.gitignore
    !/bin/
    !/config/packages/*

(将

!/bin
添加到
.gitignore
与此错误无关,但从 symfony 6 开始不应再忽略它,并且是修复此其他错误的解决方案:
Script cache:clear returned with error code 1

Could not open input file: ./bin/console).
当您从 git 安装 symfony 项目时。


0
投票

需要文件

config/packages/doctrine.yaml
,至少包含:

doctrine:
  dbal:

然后错误就消失了。

其余配置请参阅配置参考

© www.soinside.com 2019 - 2024. All rights reserved.