Skip to content

Commit

Permalink
Rabbitmq: fetch server url from env, default to localhost
Browse files Browse the repository at this point in the history
* user can set RABBITMQ_MGMT_URL, USER & PASS to setup rabbitmq
  managment api location & credentials.
  • Loading branch information
tom-etna committed Dec 9, 2021
1 parent cbede03 commit 2af827e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/RabbitMQ.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ trait RabbitMQ
{
static private function getRabbitMqClient()
{
$base_url = getenv("RABBITMQ_MGMT_URL") ?: "http://localhost:15672";
$user = getenv("RABBITMQ_USER") ?: "guest";
$password = getenv("RABBITMQ_PASS") ?: "guest";

return new Client([
"base_uri" => "http://127.0.0.1:15672",
"base_uri" => $base_url,
"headers" => ["Content-Type" => "application/json"],
"auth" => ["guest", "guest"]
"auth" => [$user, $password]
]);
}

Expand Down

0 comments on commit 2af827e

Please sign in to comment.