安装期间出现 Symfony 4 和 Sonata News Bundle 错误
Symfony 4 and Sonata News Bundle Error during Intallation
我在安装 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 的官方文档。
有人可以帮忙吗?
文档中缺少一个步骤 - 看起来我们需要手动添加一个额外的包来创建缺少的 类:
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
命名空间中创建 类。
如果他们不这样做,就会像上面那样需要手动添加一些东西。
我在安装 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 的官方文档。
有人可以帮忙吗?
文档中缺少一个步骤 - 看起来我们需要手动添加一个额外的包来创建缺少的 类:
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
命名空间中创建 类。
如果他们不这样做,就会像上面那样需要手动添加一些东西。