symfonyredissymfony-2.6

SncRedisBundle not working, what am I doing wrong?


snc_redis:
    clients:
        default:
            type: predis
            alias: default
            dsn: redis://localhost
    session:
        client: session
        prefix: session_
        use_as_default: true

The above is my current snc_redis config in config.yml I added defined snc_redis as my session handler id by doing the following:

framework:
    ...
    session:
        handler_id: snc_redis.session.handler

The error I get:

  The service definition "snc_redis.session_client" does not exist.

and when I delete the line client: session, it still fails:

The child node "client" at path "snc_redis.session" must be configured.

Solution

  • In your config.yml file, try to add this:

    # config.yml
    snc_redis:
        clients:
            default:
                type: predis
                alias: default
                dsn: redis://%redis_address%
                logging: %kernel.debug%
            session:
                type: predis
                alias: session
                dsn: redis://%redis_address%/1
                logging: true
        session:
            client: session
            prefix: %project_name%
    

    This will set 2 clients, default and cache. You could use default to handle caching for data, and session so that the session stuff is handled. If you only have 1 shard, you could just remove the session client (snc_redis.clients.session), and then set the snc_redis.session.client to default

    Regarding the framework part, try this:

    framework:
        ...
        session: ~
    

    The SncRedisBundle will then manage sessions for you based on the first configuration. The second configuration just tells Symfony to keep defaulting.

    Tell me if it works or not, and I'll edit accordingly :)