@@ -88,7 +88,7 @@ Run the following command to start it:
88
88
Configuration
89
89
-------------
90
90
91
- The preferred way to configure the Mercure Bundle is using
91
+ The preferred way to configure the MercureBundle is using
92
92
:doc: `environment variables </configuration >`.
93
93
94
94
Set the URL of your hub as the value of the ``MERCURE_PUBLISH_URL `` env var.
@@ -127,7 +127,7 @@ public updates (see the authorization_ section for further informations).
127
127
.. caution ::
128
128
129
129
Don't put the secret key in ``MERCURE_JWT_SECRET ``, it will not work!
130
- This env var must contain a JWT, signed with the secret key.
130
+ This environment variable must contain a JWT, signed with the secret key.
131
131
132
132
Also, be sure to keep both the secret key and the JWTs... secrets!
133
133
@@ -143,9 +143,7 @@ updates to the Hub.
143
143
144
144
The ``Publisher `` service can be injected using the
145
145
:doc: `autowiring </service_container/autowiring >` in any other
146
- service, including controllers:
147
-
148
- .. code-block :: php
146
+ service, including controllers::
149
147
150
148
// src/Controller/PublishController.php
151
149
namespace App\Controller;
@@ -176,7 +174,7 @@ the **topic** being updated. This topic should be an IRI_
176
174
of the resource being dispatched.
177
175
178
176
Usually, this parameter contains the original URL of the resource
179
- transmitted to the client, but it can be any valid IRI , it doesn't
177
+ transmitted to the client, but it can be any valid IRI _ , it doesn't
180
178
have to be an URL that exists (similarly to XML namespaces).
181
179
182
180
The second parameter of the constructor is the content of the update.
@@ -245,9 +243,7 @@ and to configure properly a transport (if you don't, the handler will
245
243
be called synchronously).
246
244
247
245
Then, dispatch the Mercure ``Update `` to the Messenger's Message Bus,
248
- it will be handled automatically:
249
-
250
- .. code-block :: php
246
+ it will be handled automatically::
251
247
252
248
// src/Controller/PublishController.php
253
249
namespace App\Controller;
@@ -281,11 +277,8 @@ in a ``Link`` HTTP header.
281
277
282
278
.. image :: /_images/mercure/discovery.png
283
279
284
- Symfony makes it easy to create ``Link `` headers thanks to
285
- :doc: `WebLink Component </web_link >`.
286
- Install it, then use it through the ``AbstractController::addLink `` helper method:
287
-
288
- .. code-block :: php
280
+ You can create ``Link `` headers with the :doc: `WebLink Component </web_link >`,
281
+ by using the ``AbstractController::addLink `` helper method::
289
282
290
283
// src/Controller/DiscoverController.php
291
284
namespace App\Controller;
@@ -299,7 +292,8 @@ Install it, then use it through the ``AbstractController::addLink`` helper metho
299
292
{
300
293
public function __invoke(Request $request): JsonResponse
301
294
{
302
- $hubUrl = $this->getParameter('mercure.default_hub'); // This parameter is automatically created by the MercureBundle
295
+ // This parameter is automatically created by the MercureBundle
296
+ $hubUrl = $this->getParameter('mercure.default_hub');
303
297
304
298
// Link: <http://localhost:3000/hub>; rel="mercure"
305
299
$this->addLink($request, new Link('mercure', $hubUrl));
@@ -338,9 +332,7 @@ Authorization
338
332
339
333
Mercure also allows to dispatch updates only to authorized clients.
340
334
To do so, set the list of **targets ** allowed to receive the update
341
- as the third parameter of the ``Update `` constructor:
342
-
343
- .. code-block :: php
335
+ as the third parameter of the ``Update `` constructor::
344
336
345
337
// src/Controller/Publish.php
346
338
namespace App\Controller;
@@ -388,9 +380,7 @@ To generate the JWT, we'll use the ``lcobucci/jwt`` library. Install it:
388
380
389
381
$ composer require lcobucci/jwt
390
382
391
- And here is the controller:
392
-
393
- .. code-block :: php
383
+ And here is the controller::
394
384
395
385
// src/Controller/DiscoverController.php
396
386
namespace App\Controller;
@@ -436,9 +426,7 @@ Generating Programmatically The JWT Used to Publish
436
426
437
427
Instead of directly storing a JWT in the configuration,
438
428
you can create a service that will return the token used by
439
- the ``Publisher `` object.
440
-
441
- .. code-block :: php
429
+ the ``Publisher `` object::
442
430
443
431
// src/Mercure/MyJwtProvider.php
444
432
namespace App\Mercure;
@@ -510,9 +498,7 @@ Start by installing the library using its official recipe:
510
498
$ composer require api
511
499
512
500
Then, creating the following entity is enough to get a fully-featured
513
- hypermedia API, and automatic update broadcasting through the Mercure hub:
514
-
515
- .. code-block :: php
501
+ hypermedia API, and automatic update broadcasting through the Mercure hub::
516
502
517
503
// src/Entity/Book.php
518
504
namespace App\Entity;
0 commit comments