Skip to content

Instantly share code, notes, and snippets.

@jasonmccallister
Created October 26, 2013 20:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonmccallister/7174098 to your computer and use it in GitHub Desktop.
Save jasonmccallister/7174098 to your computer and use it in GitHub Desktop.
My Craft db.php configuration for AppFog.com
<?php
/**
* Database Configuration
*
* All of your system's database configuration settings go in here.
* You can see a list of the default settings in craft/app/etc/config/defaults/db.php
*/
if ($_SERVER['HTTP_HOST'] == 'local.domainname.com') {
$var_servername = '';
$var_username = '';
$var_password = '';
$var_database = '';
} else {
$services_json = json_decode(getenv("VCAP_SERVICES"),true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"];
$var_servername = $mysql_config["hostname"];
$var_username = $mysql_config["username"];
$var_password = $mysql_config["password"];
$var_database = $mysql_config["name"];
}
return array(
// The database server name or IP address. Usually this is 'localhost' or '127.0.0.1'.
'server' => $var_servername,
// The database username to connect with.
'user' => $var_username,
// The database password to connect with.
'password' => $var_password,
// The name of the database to select.
'database' => $var_database,
// The prefix to use when naming tables. This can be no more than 5 characters.
'tablePrefix' => 'craft',
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment