Skip to content

Commit 4479c32

Browse files
committed
Tweaks
1 parent d6ae647 commit 4479c32

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

mercure.rst

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@ can be downloaded as a static binary from `Mercure.rocks`_.
5757
A Docker image, a Helm chart for Kubernetes
5858
and a managed, High Availability Hub are also provided.
5959

60-
If you use `Symfony Docker`_ or the `API Platform distribution`_,
61-
a Mercure Hub is automatically installed and your Symfony application
62-
is automatically configured to use it.
63-
You can jump directly to the next section.
60+
If you use `Symfony Docker`_ or the `API Platform distribution`_, a Mercure Hub
61+
is automatically installed and your Symfony application is automatically
62+
configured to use it. You can jump directly to the next section.
6463

6564
If you use the :doc:`Symfony Local Web Server </setup/symfony_server>`,
66-
a Mercure hub will be automatically available as a Docker service thanks to its :ref:`Docker integration <symfony-server-docker>.
65+
a Mercure hub will be automatically available as a Docker service thanks to its
66+
:ref:`Docker integration <symfony-server-docker>.
6767

68-
Be sure that recent versions of Docker and Docker Compose are properly installed on your computer
69-
and to start the Symfony Local Web Server with the ``--no-tls`` option:
68+
Be sure that recent versions of Docker and Docker Compose are properly installed
69+
on your computer and to start the Symfony Local Web Server with the ``--no-tls``
70+
option:
7071

7172
.. code-block:: terminal
7273
@@ -81,9 +82,9 @@ Run this command to install the Mercure support before using it:
8182
8283
$ composer require mercure
8384
84-
:ref:`Symfony Flex <symfony-flex>` has automatically installed and configured MercureBundle.
85-
It also created (if needed) and configured a Docker Compose definition that provides a Mercure service.
86-
Run ``docker-compose up`` to start it.
85+
:ref:`Symfony Flex <symfony-flex>` has automatically installed and configured
86+
MercureBundle. It also created (if needed) and configured a Docker Compose
87+
definition that provides a Mercure service. Run ``docker-compose up`` to start it.
8788

8889
Configuration
8990
-------------
@@ -94,8 +95,9 @@ The preferred way to configure the MercureBundle is using
9495
When MercureBundle has been installed, the ``.env`` file of your project
9596
has been updated by the Flex recipe to include the available env vars.
9697

97-
If you use the Symfony Local Web Server, Symfony Docker or the API Platform distribution,
98-
the Symfony app is automatically configured and you can skip straight to the next section.
98+
If you use the Symfony Local Web Server, Symfony Docker or the API Platform
99+
distribution, the Symfony app is automatically configured and you can skip
100+
straight to the next section.
99101

100102
Otherwise, set the URL of your hub as the value of the ``MERCURE_URL``
101103
and ``MERCURE_PUBLIC_URL`` env vars.
@@ -251,10 +253,12 @@ Subscribing to updates in JavaScript from a Twig template is straightforward:
251253
}
252254
<script>
253255
254-
The ``mercure()`` Twig function will generate the URL of the Mercure hub according to the configuration.
255-
The URL will include the ``topic`` query parameters corresponding to the topics passed as first argument.
256+
The ``mercure()`` Twig function will generate the URL of the Mercure hub
257+
according to the configuration. The URL will include the ``topic`` query
258+
parameters corresponding to the topics passed as first argument.
256259

257-
If you want to access to this URL from an external JavaScript file, generate the URL in a dedicated HTML element:
260+
If you want to access to this URL from an external JavaScript file, generate the
261+
URL in a dedicated HTML element:
258262

259263
.. code:: twig
260264
@@ -397,11 +401,11 @@ a JWT containing a topic selector matching by the update's topic.
397401
To provide this JWT, the subscriber can use a cookie,
398402
or a ``Authorization`` HTTP header.
399403

400-
Cookies can be set automatically by Symfony by passing the appropriate options to the ``mercure()`` Twig function.
401-
Cookies set by Symfony will be automatically passed by the browsers to the Mercure hub
402-
if the ``withCredentials`` attribute of the ``EventSource`` class is set to ``true``.
403-
Then, the Hub will verify the validity of the provided JWT, and extract the topic selectors
404-
from it.
404+
Cookies can be set automatically by Symfony by passing the appropriate options
405+
to the ``mercure()`` Twig function. Cookies set by Symfony will be automatically
406+
passed by the browsers to the Mercure hub if the ``withCredentials`` attribute
407+
of the ``EventSource`` class is set to ``true``. Then, the Hub will verify the
408+
validity of the provided JWT, and extract the topic selectors from it.
405409

406410
.. code-block:: twig
407411
@@ -413,8 +417,8 @@ from it.
413417
414418
The supported options are:
415419

416-
* ``subscribe``: the list of topic selectors to include in the ``mercure.subscribe`` claim of the JWT
417-
* ``publish``: the list of topic selectors to include in the ``mercure.publish`` claim of the JWT
420+
* ``subscribe``: the list of topic selectors to include in the ``mercure.subscribe`` claim of the JWT
421+
* ``publish``: the list of topic selectors to include in the ``mercure.publish`` claim of the JWT
418422
* ``additionalClaims``: extra claims to include in the JWT (expiration date, token ID...)
419423

420424
Using cookies is the most secure and preferred way when the client is a web
@@ -444,12 +448,12 @@ is the way to go.
444448
Programmatically Setting The Cookie
445449
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
446450

447-
Sometimes, it can be convenient to set the authorization cookie from
448-
your code instead of using the Twig function.
449-
MercureBundle provides a convenient service, :class:`Symfony\\Component\\Mercure\\Authorization`, to do so.
451+
Sometimes, it can be convenient to set the authorization cookie from your code
452+
instead of using the Twig function. MercureBundle provides a convenient service,
453+
:class:`Symfony\\Component\\Mercure\\Authorization`, to do so.
450454

451-
In the following example controller,
452-
the added cookie contains a JWT, itself containing the appropriate topic selector.
455+
In the following example controller, the added cookie contains a JWT, itself
456+
containing the appropriate topic selector.
453457

454458
And here is the controller::
455459

@@ -714,9 +718,10 @@ it will be handled automatically::
714718
Going further
715719
-------------
716720

717-
* The Mercure protocol is also supported by :doc:`the Notifier component </notifier>`. Use it to send push notifications to web browsers.
718-
* `Symfony UX Turbo`_ is a library using Mercure to provide the same experience as with Single Page Applications but without having to write a single line of JavaScript!
719-
721+
* The Mercure protocol is also supported by :doc:`the Notifier component </notifier>`.
722+
Use it to send push notifications to web browsers.
723+
* `Symfony UX Turbo`_ is a library using Mercure to provide the same experience
724+
as with Single Page Applications but without having to write a single line of JavaScript!
720725

721726
.. _`the Mercure protocol`: https://mercure.rocks/spec
722727
.. _`Server-Sent Events (SSE)`: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events

0 commit comments

Comments
 (0)