首页 > 解决方案 > “传递给 ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory::__construct() 的参数 1 必须是一个实例......”

问题描述

在尝试安装 Api-Platform(或composer update在现有的 Api-Platform 安装上运行时,我收到如下错误:

未捕获的错误:参数 1 传递给 ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory::__construct() 必须是 Doctrine\Common\Persistence\ManagerRegistry 的实例,给定的 Doctrine\Bundle\DoctrineBundle\Registry 实例,在 App_KernelDevDebugContainer.php 的第 1530 行调用 ["exception" => TypeError { …}]

我该怎么做才能正确安装 Api-Platform?为什么更新失败?

标签: phpsymfonydoctrine-ormcomposer-phpapi-platform.com

解决方案


在发布新版本的 Api-Platform 之前(可能会相对较快),您可以通过将其添加到您的composer.json

"conflict": {
    "doctrine/common": ">= 3.0",
    "doctrine/persistence": "^1.0"
}

(由于您可能已经有一个conflict密钥,只需将一行添加到您现有的conflict规则中)。

新版本doctrine/common发布,当前版本的Api-Platform不兼容。

在不久的将来某个时候,一旦发布了新版本的 Api-Platform,您就可以删除该行。

是一个问题,您可以在其中密切关注讨论,并希望在此捆绑包级别上跟踪问题何时得到解决。


这不再是必要的。您可以使用最新的 Api-Platform 包更新到最新的 Doctrine 包,并且每个包都可以正常工作。


推荐阅读