如何使用ApcuCache与Symfony,Doctrine ORM和DoctrineCacheBundle

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

在我遇到这个问题之前,该项目在SF2.6上的PHP5.6上运行。

现在我使用PHP7.1.20和SF2.8。我在我的docker容器中安装了apcu和apcu_bc并启用了apcu php模块。

现在的错误是:

UndefinedFunctionException in ApcCache.php line 35:
Attempted to call function "apc_exists" from the global namespace.

当我将加载的ApcCache-Class内部的实际函数调用从apc_更改为apcu_时一切正常。

在Doctrine \ Common \ Cache里面都是类,ApcCache-和ApcuCache-Class。我不知道如何告诉doctrine ORM / CacheBundle使用ApcuCache-Class而不是Apc one。

学说配置:

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                driver:   "%database_driver%"
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8
                persistent: true
                wrapper_class: 'Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection'
                driver_class: 'Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Driver\PDOMySql\Driver'
                server_version: '5.7'
                options:
                    x_reconnect_attempts: 3
            jato:
                driver:   "%database_jato_driver%"
                host:     "%database_jato_host%"
                port:     "%database_jato_port%"
                dbname:   "%database_jato_name%"
                user:     "%database_jato_user%"
                password: "%database_jato_password%"
                charset:  UTF8
                persistent: true
                server_version: '5.7'

            drupal:
                driver:   "%database_drupal_driver%"
                host:     "%database_drupal_host%"
                port:     "%database_drupal_port%"
                dbname:   "%database_drupal_name%"
                user:     "%database_drupal_user%"
                password: "%database_drupal_password%"
                charset:  UTF8
                persistent: true
                server_version: '5.7'

        types:
            json: Sonata\Doctrine\Types\JsonType

    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                mappings:
                    SonataMediaBundle: ~
                    ApplicationSonataMediaBundle: ~
                    XFrontendBundle: ~
                query_cache_driver:
                    type: service
                    id: doctrine_cache.providers.chain_cache
                metadata_cache_driver:
                    type: service
                    id: doctrine_cache.providers.chain_cache
                result_cache_driver:
                    type: service
                    id: doctrine_cache.providers.chain_cache

            jato:
                connection: jato
                mappings:
                    XBackendBundle: ~
                query_cache_driver: array
                metadata_cache_driver: array
                result_cache_driver: array
            drupal:
                connection: drupal

DoctrineCacheBundle配置:

doctrine_cache:
    providers:
        chain_cache:
            chain:
                providers: [array_cache, apc_cache]
        apc_cache:
            type: apc
        array_cache:
            type: array

在缓存的服务容器(app / cache / prod / appProdProjectContainer.php)中,我可以找到以下信息:

'doctrine_cache.providers.apc_cache' => 'getDoctrineCache_Providers_ApcCacheService',

其次是

/*
     * Gets the public 'doctrine_cache.providers.apc_cache' shared service.
     *
     * @return \Doctrine\Common\Cache\ApcCache
     */
    protected function getDoctrineCache_Providers_ApcCacheService()
    {
        return $this->services['doctrine_cache.providers.apc_cache'] = new \Doctrine\Common\Cache\ApcCache();
    }

 'validator.mapping.cache.apc.class' => 'Symfony\\Component\\Validator\\Mapping\\Cache\\ApcCache',

'doctrine_cache.apc.class' => 'Doctrine\\Common\\Cache\\ApcCache',
'doctrine.orm.cache.apc.class' => 'Doctrine\\Common\\Cache\\ApcCache',

我需要配置或更新等以实现只使用ApcuCache-Class而不是Apc。

其他作曲家信息:

doctrine/cache                           v1.8.0
doctrine/annotations                     v1.6.0             
doctrine/cache                           v1.8.0             
doctrine/collections                     v1.5.0             
doctrine/common                          v2.9.0             
doctrine/dbal                            v2.4.5             
doctrine/doctrine-bundle                 1.6.13             
doctrine/doctrine-cache-bundle           dev-master 
doctrine/event-manager                   v1.0.0             
doctrine/inflector                       v1.3.0             
doctrine/instantiator                    1.1.0              
doctrine/lexer                           v1.0.1             
doctrine/orm                             v2.4.8             
doctrine/persistence                     v1.0.1             
doctrine/reflection                      v1.0.0  

symfony/assetic-bundle                   v2.8.2             
symfony/monolog-bundle                   v2.12.1           
symfony/polyfill-apcu                    v1.9.0             
symfony/polyfill-ctype                   v1.9.0             
symfony/polyfill-intl-icu                v1.9.0             
symfony/polyfill-mbstring                v1.9.0             
symfony/polyfill-php54                   v1.9.0             
symfony/polyfill-php55                   v1.9.0             
symfony/polyfill-php56                   v1.9.0             
symfony/polyfill-php70                   v1.9.0             
symfony/polyfill-util                    v1.9.0             
symfony/security-acl                     v3.0.1             
symfony/swiftmailer-bundle               v2.6.7             
symfony/symfony                          v2.8.45

sonata-project/admin-bundle              3.39.0             
sonata-project/block-bundle              3.12.1             
sonata-project/cache                     2.0.1              
sonata-project/core-bundle               3.11.2             
sonata-project/datagrid-bundle           2.3.1              
sonata-project/doctrine-extensions       1.0.2              
sonata-project/doctrine-orm-admin-bundle 3.4.2              
sonata-project/easy-extends-bundle       2.5.0              
sonata-project/exporter                  1.9.1              
sonata-project/formatter-bundle          3.5.0              
sonata-project/intl-bundle               2.5.0              
sonata-project/jquery-bundle             1.10.2             
sonata-project/markitup-bundle           2.1.0              
sonata-project/media-bundle              3.15.0 

容器调试信息:

Information for Service "doctrine_cache.providers.apc_cache"
============================================================

 ------------------ ------------------------------------
  Option             Value
 ------------------ ------------------------------------
  Service ID         doctrine_cache.providers.apc_cache
  Class              Doctrine\Common\Cache\ApcCache
  Tags               -
  Scope              container
  Public             yes
  Synthetic          no
  Lazy               no
  Synchronized       no
  Abstract           no
  Autowired          no
  Autowiring Types   -
 ------------------ ------------------------------------    

我想这是正确的服务,我必须配置为使用ApcuCache-Class而不是实际的ApcCache-Class。

谢谢你们的帮助非常感谢。

php symfony caching doctrine apcu
1个回答
0
投票

... ... ...

它可能只是覆盖实际的服务......

@ / src / App / Bundle / Resources / config / services.yml:

doctrine_cache.providers.apc_cache:
        class: Doctrine\Common\Cache\ApcuCache

好吧..第一次symfony / doctrine / ...艰难地学习......

任何进一步的解释仍然非常感谢。

有一个很好的。

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