gpt4 book ai didi

php - 更新 Doctrine 后 Symfony 中的 "compatibility between ObjectManager and EntityManagerInterface "是什么?

转载 作者:行者123 更新时间:2023-12-04 11:55:36 24 4
gpt4 key购买 nike

在我的 Symfony 项目中尝试更新( composer update )后出现错误。

我寻找了一个解决方案,我发现有必要修改实体和构造函数中的使用和类型提示..我已经完成了!

然后,我重新启动了更新,但发生了不同的错误并且更新未完全完成。

结果:我的网站已关闭并显示兼容性错误。

看这个:

Compile Error: Declaration of App\DataFixtures\AppFixtures::load(Doctrine\ORM\EntityManagerInterface $manager) must be compatible with Doctrine\Common\DataFixtures\FixtureInterface::load(Doctrine\Common\Persistence\ObjectManager $manager) in AppFixtures.php line 8`



我不明白,兼容性是什么?

我不知道如何发布我的代码..( Controller 、YAML、实体、..)但我尝试了。
我的项目在 bug 出现之前就在 GitHub 上,也许它会很有用(如果你需要……)

这是我的 AppFixtures.php :

<?php

namespace App\DataFixtures;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\ORM\EntityManagerInterface;

class AppFixtures extends Fixture
{
public function load(EntityManagerInterface $manager)
{
// $product = new Product();
// $manager->persist($product);

$manager->flush();
}
}

最佳答案

我想现在用 symfony 4.3 更正 lhor kostrov,
您需要使用来自 Doctrine\Persistence\ObjectManager 的 ObjectManager
而不是来自 Doctrine\Common\Persistence\ObjectManager

关于php - 更新 Doctrine 后 Symfony 中的 "compatibility between ObjectManager and EntityManagerInterface "是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59212113/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com