For all the site configurations I use quite a lengthy amount of code,
e.g. for the WP Redis plugin:
// Redis cache server config (WP Redis plugin)
if(env('REDIS_HOST'))
$_SERVER['CACHE_HOST'] = env('REDIS_HOST');
$_SERVER['CACHE_PORT'] = env('REDIS_PORT'); // WP Redis plugin expects a defined PORT
if(env('REDIS_PASSWORD'))
$_SERVER['CACHE_PASSWORD'] = env('REDIS_PASSWORD');
if(env('REDIS_SALT'))
Config::define('WP_CACHE_KEY_SALT', env('REDIS_SALT')); // salt uses a constant instead of `$_SERVER` !
if(env('REDIS_DB_NO'))
$_SERVER['CACHE_DB'] = env('REDIS_DB_NO');
This allows me to set all the redis specific configuration inside the site .env
or ansible
configuration in Trellis
.
However, this code can and does change and it would be nice to reuse it between many sites.