Skip to content

Instantly share code, notes, and snippets.

@mfdj
Last active August 29, 2015 14:03
Show Gist options
  • Save mfdj/39d77413cb7aaa4036ef to your computer and use it in GitHub Desktop.
Save mfdj/39d77413cb7aaa4036ef to your computer and use it in GitHub Desktop.
Extract database-related and other parameters from PagodaBox's environment — override parameters.yml and keep your secrets out of your repo
# file: app/config/config.yml
imports:
- { resource: parameters.yml }
- { resource: parameters_pagoda.php } # import after parameters.yml to override it's values
- { resource: security.yml }
# file: app/config/parameters_pagoda.php
<?php
// • Database Info
// DB1_* vars provided by PagodaBox for the first database.
// DB2_* for the second,
// etc. …
if (isset($_SERVER['DB1_NAME']))
{
$container->setParameter('database_name', $_SERVER['DB1_NAME']);
$container->setParameter('database_host', $_SERVER['DB1_HOST']);
$container->setParameter('database_port', $_SERVER['DB1_PORT']);
$container->setParameter('database_user', $_SERVER['DB1_USER']);
$container->setParameter('database_password', $_SERVER['DB1_PASS']);
}
// • User Values
// Keep credentials out of the repo!
// see: PagodBox > Admin > Environment > Vars
foreach (['deployment' => 'DEPLOYMENT',
'secret' => 'SYMFONY_SECRET',
// etc…
] as $to => $from)
{
if (isset($_SERVER[$from]))
$container->setParameter($to, $_SERVER[$from]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment