【问题标题】:Symfony 4 and Sonata News Bundle Error during IntallationSymfony 4 和 Sonata News Bundle 在安装过程中出错
【发布时间】:2019-11-13 00:56:18
【问题描述】:

在安装 SonataNewsBundle 时出现以下错误。

Unable to register extension "Sonata\FormatterBundle\Extension\ControlFlowExtension" as it is already registered in . (which is being imported from "/home/yoesoff/Documents/projects/oblog/config/routes/sonata_admin.yaml"). Make sure there is a loader supporting the "sonata_admin" type.

以下错误

The target-entity App\Entity\SonataMediaMedia cannot be found in 'App\Entity\SonataClassificationCollection#media'.

我只是关注here的官方文档。

有人可以帮忙吗?

【问题讨论】:

  • 据我了解 Flex 应该 创建 App\Entity\SonataMediaMedia 而不是我们必须使用简单的扩展来在 App\Application 命名空间中生成实体,但这似乎没有发生.虽然不知道该怎么办......
  • Yusuf 您找到第一个错误的解决方案了吗? '无法注册扩展“Sonata\FormatterBundle\Extension\ControlFlowExtension”,因为它已经在 . (从“/home/yoesoff/Documents/projects/oblog/config/routes/sonata_admin.yaml”导入)。确保有一个支持“sonata_admin”类型的加载器。'

标签: php sonata-admin sonata symfony-4.3


【解决方案1】:

文档中缺少一个步骤 - 看起来我们需要手动添加一个额外的包来创建缺少的类:

composer require sonata-project/media-orm-pack

请注意,如果您使用的是sonata-project/classification-bundle,则需要像这样修复App\Entity\SonataMediaMedia::$category 的注释:

/**
 * ORM\ManyToOne(
 *     targetEntity="App\Entity\SonataClassificationCategory",
 *     cascade={"persist"}
 * )
 * ORM\JoinColumn(name="category_id", referencedColumnName="id", onDelete="SET NULL")
 *
 * @var SonataClassificationCategory
 */
protected $category;

如果有帮助,据我了解,在使用 Symfony 4 / Flex 时,我们应该跳过 sonata:easy-extends:generate 步骤。

Flex 配方应该在我们的 App\Entity 命名空间中创建类。

如果他们不这样做,则需要手动添加上述内容。

【讨论】:

    猜你喜欢
    • 2018-10-13
    • 2018-04-19
    • 2018-01-12
    • 2018-01-16
    • 2018-07-03
    • 2018-07-04
    • 2021-03-25
    • 2019-02-13
    • 1970-01-01
    相关资源
    最近更新 更多