dflydev / dflydev-doctrine-orm-service-provider

Doctrine ORM Service Provider
MIT License
209 stars 59 forks source link

question : how to set redis options ? #73

Open davidbarre opened 8 years ago

davidbarre commented 8 years ago

Hi,

I try to set this redis option in my provider declaration :

Uncaught exception 'RuntimeException' with message 'Host and port options need to be specified for redis cache'

Where I have to set this option ? Thanks for your answers.

I try this :

$app->register(new DoctrineOrmServiceProvider(), array(
    'orm.proxies_dir' => __DIR__."/../../cache/doctrineProxies",
    'orm.proxies_namespace' => $app['env'],
    'orm.auto_generate_proxies' => $app['debug'],
    'orm.default_cache' => getenv('REDIS_CACHE') ? 'redis' : 'array',
    'host' => getenv('REDIS_HOST'),
    'port' => getenv('REDIS_PORT'),
    'password' => getenv('REDIS_PASSWORD'),
    'orm.em.options' => array(
        'cache_namespace' => $app['env'].'_',
        'mappings' => array(
            array(
                'type' => 'annotation',
                'namespace' => 'Models',
                'path' => '',
            ),
        ),
    ),
));

also this

$app->register(new DoctrineOrmServiceProvider(), array(
    'orm.proxies_dir' => __DIR__."/../../cache/doctrineProxies",
    'orm.proxies_namespace' => $app['env'],
    'orm.auto_generate_proxies' => $app['debug'],
    'orm.default_cache' => getenv('REDIS_CACHE') ? 'redis' : 'array',
    'orm.em.options' => array(
        'cache_namespace' => $app['env'].'_',
        'host' => getenv('REDIS_HOST'),
        'port' => getenv('REDIS_PORT'),
        'password' => getenv('REDIS_PASSWORD'),
        'mappings' => array(
            array(
                'type' => 'annotation',
                'namespace' => 'Models',
                'path' => '',
            ),
        ),
    ),
));
davidbarre commented 8 years ago

OK I find the right syntax...

$app->register(new DoctrineOrmServiceProvider(), array(
    'orm.proxies_dir' => __DIR__."/../../cache/doctrineProxies",
    'orm.proxies_namespace' => $app['env'],
    'orm.auto_generate_proxies' => $app['debug'],
    'orm.default_cache' => array(
        'driver' => 'redis', 
        'host' => getenv('REDIS_HOST'),
        'port' => getenv('REDIS_PORT'),
        'password' => getenv('REDIS_PASSWORD'),
   ),
   'orm.em.options' => array(
        'cache_namespace' => $app['env'].'_',
        'mappings' => array(
            array(
                'type' => 'annotation',
                'namespace' => 'Models',
                'path' => '',
            ),
        ),
    ),
));