Orm: Parameterize redis server IP

Created on 9 Nov 2018  路  4Comments  路  Source: doctrine/orm

| Q | A
|------------ | -----
| Version | 2.5.14

My php server has the redis extension loaded, but my redis server instance are in another server. So, when I run my app is displayed the RedisException below:

Fatal error: Uncaught exception 'RedisException' with message 'Connection refused' in /var/www/middlewares/vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Setup.php:200

Below the code regarding this exception:

if (extension_loaded('redis')) {
    $redis = new \Redis();
    $redis->connect('127.0.0.1');   <------ Server IP

    $cache = new \Doctrine\Common\Cache\RedisCache();
    $cache->setRedis($redis);

    return $cache;
}

So, basically it was good if the redis server IP was parameterized in Doctrine config options.

Improvement Question

Most helpful comment

So, basically it was good if the redis server IP was parameterized in Doctrine config options.

I'm excluding this upfront. The if (extension_loaded('redis')) { block should rather disappear, but the setup utilities are in place to aid in getting started there, they are surely not meant to be highly configurable.

All 4 comments

Sorry, incorrectly moved this issue. I think the entire Doctrine\ORM\Tools\Setup is kinda foobar'd. Probably a better idea to leave this to PSR-11 providers like https://github.com/DASPRiD/container-interop-doctrine, in future.

Thoughts, @doctrine/doctrinecore?

So, basically it was good if the redis server IP was parameterized in Doctrine config options.

I'm excluding this upfront. The if (extension_loaded('redis')) { block should rather disappear, but the setup utilities are in place to aid in getting started there, they are surely not meant to be highly configurable.

I think the entire Doctrine\ORM\Tools\Setup is kinda foobar'd.

As discussed with @lcobucci some time ago, we should either drop the Setup class altogether in 3.0 or at least drop the magic around caching configuration - it makes a lot of naive assumptions, especially when creating the cache instance.

Was this page helpful?
0 / 5 - 0 ratings