Skip to content

Instantly share code, notes, and snippets.

@xpersonas
Last active March 15, 2017 18:43
Show Gist options
  • Save xpersonas/89006b676e299be608859858f327afb7 to your computer and use it in GitHub Desktop.
Save xpersonas/89006b676e299be608859858f327afb7 to your computer and use it in GitHub Desktop.
Redis on platform.sh - parameters_platform.php
<?php
# app/config/parameters_platform.php
$relationships = getenv("PLATFORM_RELATIONSHIPS");
if (!$relationships) {
return;
}
$relationships = json_decode(base64_decode($relationships), true);
foreach ($relationships['database'] as $endpoint) {
if (empty($endpoint['query']['is_master'])) {
continue;
}
$container->setParameter('database_driver', 'pdo_' . $endpoint['scheme']);
$container->setParameter('database_host', $endpoint['host']);
$container->setParameter('database_port', $endpoint['port']);
$container->setParameter('database_name', $endpoint['path']);
$container->setParameter('database_user', $endpoint['username']);
$container->setParameter('database_password', $endpoint['password']);
$container->setParameter('database_path', '');
$container->setParameter('redis_host', 'redis://' . $relationships['redis'][0]['host']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment