首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Clear cache命令在安装api-platform.com后出现错误

Clear cache命令在安装api-platform.com后出现错误
EN

Stack Overflow用户
提问于 2020-08-25 18:21:17
回答 4查看 1.3K关注 0票数 2

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

我遵循官方文档进行安装:

代码语言:javascript
复制
composer req api

当我启动服务器或尝试运行composer install时,我收到以下错误:

代码语言:javascript
复制
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 255

然后是一个警告:

代码语言:javascript
复制
[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                  
!!                                                                                 
!!                                                                                  
!!   [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                  
!!                                                                                 
!!  
!!   // Clearing the cache for the dev environment with debug                       
!!   // true                                                                        
!!  
!!  
!!  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                  
!!                                                                                 
!!  
!!  cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>
!!  
!!  2020-08-25T12:06:30+02:00 [critical] Uncaught Error: Argument 1 passed to ApiPlatform\Core\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry, instance of Doctrine\Bundle\DoctrineBundle\Registry given, called in /var/www/test-api-sf/var/cache/dev/ContainerPA69O1T/App_KernelDevDebugContainer.php on line 1040

为什么我会得到这个错误,我能做些什么来规避它?

EN

回答 4

Stack Overflow用户

发布于 2020-08-26 22:48:54

新闻:似乎在composer.json的conflict属性中添加这些行是可行的!

代码语言:javascript
复制
"conflict": {
    "symfony/symfony": "*",
    "doctrine/common": ">=3.0",
    "doctrine/persistence": "<1.3"
},

所以我从今天早上就有了这个问题,我在寻找解决方案,但没有找到,所以我把作为我自己的DIY解决方案,它对我来说非常有效。然后我将分享它:

首先,您需要进入以下路径,并使用代码编辑器打开其中的文件:

代码语言:javascript
复制
C:\YOUR_PROJECT\vendor\api-platform\core\src\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory.php

打开后,您需要将第19行 (use Doctrine\Common\Persistence\ManagerRegistry;)替换为以下行:

代码语言:javascript
复制
use Symfony\Bridge\Doctrine\ManagerRegistry;

和所有的朋友们! SCREENSHOT OF THE LINE

PS:如果您仍然有问题或没有建立供应商\api-platform,您只需打开composer.json并临时删除以下行:

代码语言:javascript
复制
"cache:clear": "symfony-cmd",

然后再次运行该命令:

代码语言:javascript
复制
composer req api
票数 1
EN

Stack Overflow用户

发布于 2020-08-26 16:02:24

从昨天开始我们就遇到了同样的问题!我尝试将捆绑包的版本更改为较旧的版本。但没有任何成功的结果。

当前依赖项:

代码语言:javascript
复制
"api-platform/api-pack": "^1.2"

但是这个问题在GitHub上已经解决了。接受测试。https://github.com/symfony/symfony/issues/37936

更新:我们必须等待api-platform捆绑包的发布。https://github.com/api-platform/core/issues/3683

票数 0
EN

Stack Overflow用户

发布于 2020-08-27 15:40:06

暂时,您可以将此代码添加到composer.json:

代码语言:javascript
复制
"conflict": {
    ...
    "doctrine/common": ">=3.0",
    "doctrine/persistence": "<1.3"
}

这对我很管用。https://github.com/api-platform/core/issues/3683#issuecomment-681039267

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63576790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档