[英]what's the " compatibility between ObjectManager and EntityManagerInterface " in Symfony after update Doctrine?
I have an error after having tried an update ( composer update ) in my Symfony project.在我的 Symfony 项目中尝试更新( composer update )后出现错误。
I looked for a solution and I found it was necessary to modify the use and the type-hint in the entity and the constructor.. which I have done!我寻找了一个解决方案,我发现有必要修改实体和构造函数中的使用和类型提示..我已经完成了!
Then, I restarted an update but a different error occurred and the update was not fully completed.然后,我重新启动了更新,但发生了不同的错误并且更新未完全完成。
Result: my site is down and a compatibility error is displayed.结果:我的网站已关闭并显示兼容性错误。
watch this:看这个:
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`
编译错误:App\\DataFixtures\\AppFixtures::load(Doctrine\\ORM\\EntityManagerInterface $manager) 的声明必须与 AppFixtures 中的 Doctrine\\Common\\DataFixtures\\FixtureInterface::load(Doctrine\\Common\\Persistence\\ObjectManager $manager) 兼容。 php第8行`
I don't understand, what the compatibility is?我不明白,兼容性是什么?
I don't know how to post my code.. ( controllers, YAML, entity, .. ) but I got try.我不知道如何发布我的代码..(控制器、YAML、实体、..)但我尝试了。 my project is on GitHub before the bug, maybe it can be useful ( if you need..)
我的项目在 bug 出现之前就在 GitHub 上,也许它会很有用(如果你需要……)
here my AppFixtures.php :这是我的 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
而不是来自Doctrine\\Common\\Persistence\\ObjectManager
In your base class Fixture
$manager instance of Doctrine\\Common\\Persistence\\ObjectManager
, so you need change EntityManagerInterface
to ObjectManager
.在
Doctrine\\Common\\Persistence\\ObjectManager
的基类Fixture
$manager 实例中,您需要将EntityManagerInterface
更改为ObjectManager
。 You cannot override typehint in children class.您不能在子类中覆盖 typehint。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.