在 Symfony 4 中使用命令行生成管理员奏鸣曲

Posted

技术标签:

【中文标题】在 Symfony 4 中使用命令行生成管理员奏鸣曲【英文标题】:Generate admin Sonata with command line in Symfony 4 【发布时间】:2019-03-16 19:30:38 【问题描述】:

我开始在 Symfony 4 中使用 Sonata。 我尝试使用命令行“make:sonata:admin”生成管理员,但在过程结束时出现错误,如下所示:

2018-10-11T15:55:23+00:00 [error] Error thrown while running command "make:sonata:admin". Message: "There are no model managers registered."
In AdminMaker.php line 286:
  There are no model managers registered.

所以我尝试使用另一个命令行“sonata:admin:generate”,但我遇到了另一个类似这样的错误:

Welcome to the AdminBundle object ACL generator
This command helps you to generate ACL entities for the objects handled by the AdminBundle.
If the step option is used, you will be asked if you want to generate the object ACL entities for each Admin.
You must use the shortcut notation like AcmeDemoBundle:User if you want to set an object owner.
Admin class is using a manager type that has no manipulator implemented : ignoring
Admin class is using a manager type that has no manipulator implemented : ignoring
Admin class is using a manager type that has no manipulator implemented : ignoring

我的实现代码是这样的:

源 实体 客户 车辆

你能帮帮我吗?

非常感谢您的回答

【问题讨论】:

【参考方案1】:

尝试配置服务,这样你就可以给你使用的模型管理器了。

services:
  sonata.admin.maker:
    class: Sonata\AdminBundle\Maker\AdminMaker
    arguments: ['%kernel.project_dir%', ['@sonata.admin.manager.orm']]
    tags:
    -  name: maker.command 

【讨论】:

以上是关于在 Symfony 4 中使用命令行生成管理员奏鸣曲的主要内容,如果未能解决你的问题,请参考以下文章

Symfony 4 + 奏鸣曲管理包 + 关系。表单正在删除子项,但不仅是 parentId

Symfony 4 为奏鸣曲管理包安装 sensio/generator-bundle 时出错

Symfony 3.2.7 和奏鸣曲媒体包安装

Symfony 形式的奏鸣曲字段类型

无法使用 symfony 5 安装奏鸣曲管理员

Symfony 2 Sonata 媒体包:在没有奏鸣曲管理员的情况下保存媒体文件图像