安装 api-platform.com 后清除缓存命令出现错误

我正在尝试安装 api-platform,但启动 Composer 安装后遇到问题:


我按照官方文档进行安装:


composer req api

当我启动服务器或尝试运行时composer install出现此错误:


Executing script cache:clear [KO]

 [KO]

Script cache:clear returned with error code 255

然后是一个警告:


[WARNING] Some commands could not be registered:                               

!!                                                                                  

!!  

!!  In DoctrineOrmPropertyMetadataFactory.php line 31:

!!                                                                                 

!!    Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property  

!!    \DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of D  

!!    octrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\Doc  

!!    trineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/Co  

!!    ntainerPA69O1T/App_KernelDevDebugContainer.php on line 1040                  

!!                                                                                 

!!  

!!  In DoctrineOrmPropertyMetadataFactory.php line 31:

!!                                                                                 

!!    Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property  

!!    \DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of D  

!!    octrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\Doc  

!!    trineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/Co  

!!    ntainerPA69O1T/App_KernelDevDebugContainer.php on line 1040                  

                                                                            


为什么我会收到此错误,我可以采取什么措施来避免它?


摇曳的蔷薇
浏览 106回答 4
4回答

侃侃无极

新闻:看来在您的composer.json中的冲突属性处添加这些行是有效的!"conflict": {&nbsp; &nbsp; "symfony/symfony": "*",&nbsp; &nbsp; "doctrine/common": ">=3.0",&nbsp; &nbsp; "doctrine/persistence": "<1.3"},所以我从今天早上就遇到了这个问题,我寻找解决方案但没有找到它,所以我制作了自己的 DIY 解决方案,它对我来说很有效然后我将分享它:首先,您需要进入以下路径并使用代码编辑器打开其中的文件:C:\YOUR_PROJECT\vendor\api-platform\core\src\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory.php打开它后,您需要将第 19 行(use Doctrine\Common\Persistence\ManagerRegistry;)替换为以下行:use Symfony\Bridge\Doctrine\ManagerRegistry;这就是大家! 线路截图PS:如果您仍然遇到问题或未找到 Vendor\api-platform,您只需打开composer.json并临时删除以下行:"cache:clear": "symfony-cmd",并再次运行命令:composer req api

喵喵时光机

从昨天开始我们就遇到了同样的问题!我尝试将捆绑包的版本更改为旧版本。但没有任何成功的结果。当前依赖:"api-platform/api-pack":&nbsp;"^1.2"不过问题在GitHub上已经解决了。待测试...&nbsp;https://github.com/symfony/symfony/issues/37936更新:我们必须等待 api 平台捆绑包的发布。&nbsp;https://github.com/api-platform/core/issues/3683

qq_花开花谢_0

暂时,您可以将其添加到composer.json:"conflict": {&nbsp; &nbsp; ...&nbsp; &nbsp; "doctrine/common": ">=3.0",&nbsp; &nbsp; "doctrine/persistence": "<1.3"}这个对我有用。 https://github.com/api-platform/core/issues/3683#issuecomment-681039267

RISEBY

我有同样的问题,但是当我添加以下行时"conflict": { ... "doctrine/common": ">=3.0", "doctrine/persistence": "<1.3" }&nbsp;在我的composer.json 文件中问题已解决
打开App,查看更多内容
随时随地看视频慕课网APP