PDO 适配器的 Symfony 缓存定义问题

问题描述 投票:0回答:1

我正在将 Symfony 5.4 项目升级到 6.2。在执行此操作时,我遇到了以下错误:

Symfony\Component\Cache\Adapter\PdoAdapter::__construct(): 参数 #1 ($connOrDsn) 必须是 PDO|string 类型,Doctrine\DBAL\Connection 给予

这是我的缓存配置:

framework:
    cache:
        default_pdo_provider: 'doctrine.dbal.default_connection'
        pools:
            login_throttling.cache:
                adapter: cache.adapter.pdo

这在 5.4 中有效,6.2 的文档也表明此配置是正确的:https://symfony.com/doc/current/cache.html

但是 symfony github 页面中的升级指南有这样的信息: https://github.com/symfony/symfony/blob/6.3/UPGRADE-6.0.md#cache

PdoAdapter 不接受 Doctrine\DBAL\Connection 或 DBAL URL。使用 取而代之的是新的 DoctrineDbalAdapter

但不清楚新适配器的名称是什么

整个方法基于此:https://blog.digital-craftsman.de/login-throttling-with-symfony-and-multiple-server-instances/

php symfony pdo
1个回答
0
投票

解决了。正确的配置在池配置中使用

cache.adapter.doctrine_dbal
而不是
cache.adapter.pdo

© www.soinside.com 2019 - 2024. All rights reserved.