[英]php Symfony2 redis class not found
我在我的 symfony2 中集成了 redis。 我用過這個圖:
http://olegpuzanov.com/2015/02/01/using-redis-for-doctrine-caching-in-symfony2/
appDevDebugProjectContainer.php 第 966 行中的 ClassNotFoundException:嘗試從全局命名空間加載 class“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();`
我還在我的應用程序 kernel 中注冊了 snc 包。
請幫忙
git clone https://github.com/phpredis/phpredis.git
cd phpredis
git checkout php7
phpize
./configure
make && make install
cd ..
rm -rf phpredis
如果您是第一次使用 redis,您必須取消注釋 php 配置的 redis 擴展並重新啟動您的服務器。 所以你的問題解決了
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.