php Symfony2 redis 类未找到

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

我正在将 redis 集成到我的 symfony2 中。我用的是这个:

http://olegpuzanov.com/2015/02/01/using-redis-for-doctrine-caching-in-symfony2/

appDevDebugProjectContainer.php 第 966 行中的 ClassNotFoundException:尝试从全局命名空间加载类“Redis”。 您是否忘记了“使用”声明?

这是我的配置:

snc_redis: # configure predis as client clients: default: type: predis alias: default dsn: redis://localhost doctrine: type: predis alias: doctrine dsn: redis://localhost # configure doctrine caching doctrine: metadata_cache: client: doctrine entity_manager: Content document_manager: default result_cache: client: doctrine entity_manager: [Content] query_cache: client: doctrine entity_manager: Content

我的疑问:

$query = $this->createQueryBuilder('c') ->select('c.id, c.title, c.sequence, c.sequence_count, c.category_sequence, c.unique_id, c.priority, c.status, c.created_at,c.kaltura_id') ->addSelect('o.slug as owner') ->addSelect('cat.slug as category') ->addSelect("group_concat(m.name SEPARATOR ',') AS media") ->addSelect("group_concat(a.name SEPARATOR ',') AS album") ->innerJoin('c.content_owner', 'o') ->innerJoin('c.category', 'cat') ->leftJoin('c.media', 'm') ->leftJoin('c.albums', 'a') ->groupBy('c.id') ->setResultCacheDriver($predis) # set cache lifetime ->setResultCacheLifetime($cache_lifetime) ->getQuery() ->getArrayResult();`

我还在我的应用程序内核中注册了 snc 包。

请帮忙

php symfony doctrine-orm redis
2个回答
0
投票
git clone https://github.com/phpredis/phpredis.git cd phpredis git checkout php7 phpize ./configure make && make install cd .. rm -rf phpredis

参见

https://gist.github.com/hollodotme/418e9b7c6ebc358e7fda


0
投票

enter image description here

如果您第一次使用redis,您必须取消注释php配置的redis扩展并重新启动服务器。那么你的问题就解决了

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