安装 symfony 项目时出现“Class Doctrine\Common\Cache\ArrayCache 不存在”

Aeg*_*ops 4 php deployment doctrine symfony doctrine-orm

我正在尝试按照以下步骤部署 symfony 项目:

./composer.phar update
php bin/console cache:clear
Run Code Online (Sandbox Code Playgroud)

我还尝试手动安装教条驱动程序 ArrayCache 运行:

./composer.phar require doctrine/cache
Run Code Online (Sandbox Code Playgroud)

结果总是相同的,我最终得到以下错误:

# ./composer.phar update --no-interaction
[...]
Script cache:clear returned with error code 255
!!
!!  In ContainerBuilder.php line 1089:
!!
!!    Class Doctrine\Common\Cache\ArrayCache does not exist
!!
!!
!!
Script @auto-scripts was called via post-update-cmd
Run Code Online (Sandbox Code Playgroud)

我是 symfony 的新手,我无法理解为什么缺少这个类。

我正在使用以下版本:

"symfony/framework-bundle": "5.1.*",
"doctrine/doctrine-bundle": "^2.2",
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助。

Eug*_*e K 10

我认为你doctrine/cache安装时安装的是2.x版本"doctrine/doctrine-bundle": "^2.2",

来自github 页面

This library is deprecated and will no longer receive bug fixes from the Doctrine Project. Please use a different cache library, preferably PSR-6 or PSR-16 instead.

所以你有以下选择:

  • composer require doctrine/cache:^1.11
  • 使用其他库进行缓存,例如symfony/cache