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

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

问题描述

我正在尝试安装 api-platform,但在启动我的 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?

推荐答案

NEWS : 在 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 解决方案,它正在工作 对我来说很漂亮 然后我要分享它:

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

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-platform,您只需要打开 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天全站免登陆