安装api-platform.com后,清除缓存命令会得到错误错误 [英] Clear cache command gets an error error after installing api-platform.com

查看:145
本文介绍了安装api-platform.com后,清除缓存命令会得到错误错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装api平台,但是在启动composer安装后遇到了问题:

I'm trying to install api-platform but I'm having problems after launching my composer install:

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

I follow the official docs for installation with:

composer req api

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

When I start the server or when I try to run composer install I get this error:

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                  
!!                                                                                 
!!                                                                                  
!!   [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

为什么会出现此错误,我该怎么做才能避免该错误?

Why am I getting this error, and what can I do to circumvent it?

推荐答案

新闻:看来在composer.json中的冲突属性处添加这些行是可行的!

NEWS : It Seems that adding these lines in your composer.json at the conflict property works !

"conflict": {
    "symfony/symfony": "*",
    "doctrine/common": ">=3.0",
    "doctrine/persistence": "<1.3"
},


所以从今天早上开始我就遇到了这个问题,我一直在寻找解决方案,却没有找到解决方案,所以我自己制作了自己的DIY解决方案,它正在起作用.strong>


So i got this problem since this morning and i looked for a solution and didn't found it so i made my own DIY solution and it's working Pretty find for me Then i'm gonna share it :

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

Firstly you need to go in the following path and open the file in it with your code editor:

C:\YOUR_PROJECT\vendor\api-platform\core\src\Bridge\Doctrine\Orm\Metadata\Property\DoctrineOrmPropertyMetadataFactory.php

打开它后,需要替换第19行(使用Doctrine \ Common \ Persistence \ ManagerRegistry; ),并添加以下内容:

Once you opened it, you need to REPLACE the line 19 (use Doctrine\Common\Persistence\ManagerRegistry;) with the following one:

use Symfony\Bridge\Doctrine\ManagerRegistry;

这就是一切!屏幕截图

PS::如果仍然遇到问题或找不到Vendor \ api平台,则只需打开 composer.json 并临时删除以下内容行:

PS: If you're still having issues or not founding the Vendor\api-platform, you just need to open the composer.json and temporary delete the Following line :

"cache:clear": "symfony-cmd",

并再次运行命令:

composer req api

这篇关于安装api-platform.com后,清除缓存命令会得到错误错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆