未知实体名称空间别名 'PirastruFormBuilderBundle'

Unknown Entity namespace alias 'PirastruFormBuilderBundle'

我已经寻找解决此错误的方法已经 2 天了,但徒劳无功:

Unknown Entity namespace alias 'PirastruFormBuilderBundle'

事实上,我使用作曲家安装了带有奏鸣曲页面包的奏鸣曲表单生成器,但我不知道为什么会出现此错误。

我不知道我应该复制哪一部分代码所以请不要犹豫向我索取

sonata_form_builder:
    resource: '@PirastruFormBuilderBundle/Controller/FormBuilderController.php'
    type:  annotation

谢谢!!

编辑

当我 运行 这个 : php app/console config:dump-reference

PirastruFormBuilderBundle | pirastru_form_builder |

当我 运行 这个: php app/console doctrine:mapping:info 我得到了

[Exception] You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for errors.

好吧,我设法解决了问题!我只需要在我的 FormBuilderBlockService

中添加一个 getManager

这个问题可能是由一些(错误的)配置引起的:

捆绑包

app/console config:dump-reference

此命令让您知道是否引用了 Bundle。

映射

app/console doctrine:mapping:info

此命令让您知道捆绑包是否已映射。

这通常是映射问题:

Unknown Entity namespace alias '***Bundle'

更好的解决方案是在config.yml中将auto_mapping添加到true中,像这样:

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true

但是可以通过其他方式解决,你可以看看:Symfony : What is the meaning of auto_mapping and auto_generate_proxy_classes

此致,