Skip to content

Instantly share code, notes, and snippets.

@lornajane
Created December 16, 2016 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lornajane/fe9c5a73d514791d5c0f19fe7c6e867b to your computer and use it in GitHub Desktop.
Save lornajane/fe9c5a73d514791d5c0f19fe7c6e867b to your computer and use it in GitHub Desktop.
if(isset($_ENV['VCAP_SERVICES'])) {
$vcap_services = json_decode($_ENV['VCAP_SERVICES'], true);
$rabbit_url = $vcap_services['compose-for-rabbitmq'][0]['credentials']['uri'];
$url_bits = parse_url($rabbit_url);
$config['rabbitmq']['host'] = $url_bits['host'];
$config['rabbitmq']['port'] = $url_bits['port'];
$config['rabbitmq']['vhost'] = substr($url_bits['path'], 1);
$config['rabbitmq']['username'] = $url_bits['user'];
$config['rabbitmq']['password'] = $url_bits['pass'];
$config['rabbitmq']['ssl'] = true;
$config['rabbitmq']['cert'] = base64_decode($vcap_services['compose-for-rabbitmq'][0]['credentials']['ca_certificate_base64']);
} else {
$config['rabbitmq']['host'] = "localhost";
$config['rabbitmq']['port'] = 5672;
$config['rabbitmq']['username'] = "guest";
$config['rabbitmq']['password'] = "guest";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment