Skip to content

Instantly share code, notes, and snippets.

@rianrainey
Last active December 15, 2015 13:29
Show Gist options
  • Save rianrainey/5267534 to your computer and use it in GitHub Desktop.
Save rianrainey/5267534 to your computer and use it in GitHub Desktop.
Drupal 7 settings.php to run on Heroku
$url = parse_url(getenv('DATABASE_URL')); // Be sure to run [heroku config:set DATABASE_URL=mysql://db_username:db_password@amazon_rds_instance_name/db_name]
$databases['default']['default'] = array(
// MySQLi uses the mysql driver.
'driver' => $url['scheme'] == 'mysqli' ? 'mysql' : $url['scheme'],
// Remove the leading slash to get the database name.
'database' => substr(urldecode($url['path']), 1),
'username' => urldecode($url['user']),
'password' => isset($url['pass']) ? urldecode($url['pass']) : '',
'host' => urldecode($url['host']),
'port' => isset($url['port']) ? urldecode($url['port']) : '',
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment