没有找到php Symfony2 redis类

时间:2015-08-12 07:51:38

标签: php symfony doctrine-orm redis

我正在将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();`

我也在我的app内核中注册了snc包。

请帮助

1 个答案:

答案 0 :(得分: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