Skip to content

Commit bf79db1

Browse files
committed
minor #20379 [Mercure] Actually using the env vars (ThomasLandauer)
This PR was submitted for the 5.4 branch but it was merged into the 6.4 branch instead. Discussion ---------- [Mercure] Actually using the env vars Page: https://symfony.com/doc/5.x/mercure.html#configuration Reasons: * The above paragraph explains how to set all those vars in `.env`, but then the code sample didn't use it ;-) * The next paragraphs recommends to use URI's for the `topic`, so changing that accordingly. Commits ------- 8f1912f Update mercure.rst: Actually using the env vars
2 parents 51d746d + 8f1912f commit bf79db1

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

Diff for: mercure.rst

+18-15
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,12 @@ MercureBundle provides a more advanced configuration:
130130
mercure:
131131
hubs:
132132
default:
133-
url: https://mercure-hub.example.com/.well-known/mercure
133+
url: '%env(string:MERCURE_URL)%'
134+
public_url: '%env(string:MERCURE_PUBLIC_URL)%'
134135
jwt:
135-
secret: '!ChangeThisMercureHubJWTSecretKey!'
136-
publish: ['foo', 'https://example.com/foo']
137-
subscribe: ['bar', 'https://example.com/bar']
136+
secret: '%env(string:MERCURE_JWT_SECRET)%'
137+
publish: ['https://example.com/foo1', 'https://example.com/foo2']
138+
subscribe: ['https://example.com/bar1', 'https://example.com/bar2']
138139
algorithm: 'hmac.sha256'
139140
provider: 'My\Provider'
140141
factory: 'My\Factory'
@@ -147,19 +148,20 @@ MercureBundle provides a more advanced configuration:
147148
<config>
148149
<hub
149150
name="default"
150-
url="https://mercure-hub.example.com/.well-known/mercure"
151-
>
151+
url="%env(string:MERCURE_URL)%"
152+
public_url="%env(string:MERCURE_PUBLIC_URL)%"
153+
> <!-- public_url defaults to url -->
152154
<jwt
153-
secret="!ChangeThisMercureHubJWTSecretKey!"
155+
secret="%env(string:MERCURE_JWT_SECRET)%"
154156
algorithm="hmac.sha256"
155157
provider="My\Provider"
156158
factory="My\Factory"
157159
value="my.jwt"
158160
>
159-
<publish>foo</publish>
160-
<publish>https://example.com/foo</publish>
161-
<subscribe>bar</subscribe>
162-
<subscribe>https://example.com/bar</subscribe>
161+
<publish>https://example.com/foo1</publish>
162+
<publish>https://example.com/foo2</publish>
163+
<subscribe>https://example.com/bar1</subscribe>
164+
<subscribe>https://example.com/bar2</subscribe>
163165
</jwt>
164166
</hub>
165167
</config>
@@ -170,11 +172,12 @@ MercureBundle provides a more advanced configuration:
170172
$container->loadFromExtension('mercure', [
171173
'hubs' => [
172174
'default' => [
173-
'url' => 'https://mercure-hub.example.com/.well-known/mercure',
175+
'url' => '%env(string:MERCURE_URL)%',
176+
'public_url' => '%env(string:MERCURE_PUBLIC_URL)%',
174177
'jwt' => [
175-
'secret' => '!ChangeThisMercureHubJWTSecretKey!',
176-
'publish' => ['foo', 'https://example.com/foo'],
177-
'subscribe' => ['bar', 'https://example.com/bar'],
178+
'secret' => '%env(string:MERCURE_JWT_SECRET)%',
179+
'publish' => ['https://example.com/foo1', 'https://example.com/foo2'],
180+
'subscribe' => ['https://example.com/bar1', 'https://example.com/bar2'],
178181
'algorithm' => 'hmac.sha256',
179182
'provider' => 'My\Provider',
180183
'factory' => 'My\Factory',

0 commit comments

Comments
 (0)